Use example config for tests
All checks were successful
Test pipeline / test (push) Successful in 11s
All checks were successful
Test pipeline / test (push) Successful in 11s
This commit is contained in:
parent
3141780dad
commit
3dd034c234
3 changed files with 35 additions and 10 deletions
|
@ -1,12 +1,9 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
import pytest
|
||||
|
||||
from doi2dataset import MetadataProcessor
|
||||
from doi2dataset import Config, MetadataProcessor
|
||||
|
||||
|
||||
class FakeResponse:
|
||||
|
@ -23,6 +20,15 @@ class FakeResponse:
|
|||
def raise_for_status(self):
|
||||
pass
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def load_config_test():
|
||||
"""
|
||||
Automatically load the configuration from 'config_test.yaml'
|
||||
located in the same directory as this test file.
|
||||
"""
|
||||
config_path = os.path.join(os.path.dirname(__file__), "config_test.yaml")
|
||||
Config.load_config(config_path=config_path)
|
||||
|
||||
@pytest.fixture
|
||||
def fake_openalex_response():
|
||||
"""
|
||||
|
@ -38,8 +44,8 @@ def test_fetch_doi_data_with_file(mocker, fake_openalex_response):
|
|||
"""
|
||||
Test fetching DOI metadata by simulating the API call with a locally saved JSON response.
|
||||
|
||||
The APIClient.make_request method is patched to return a fake response based on
|
||||
the contents of 'srep45389.json', so that no actual network request is performed.
|
||||
The APIClient.make_request method is patched to return a fake response built from the contents
|
||||
of 'srep45389.json', ensuring that the configuration is loaded from 'config_test.yaml'.
|
||||
"""
|
||||
doi = "10.1038/srep45389"
|
||||
fake_response = FakeResponse(fake_openalex_response, 200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue