Skip to content

Commit 16acb27

Browse files
committed
Add a pubmed url test.
1 parent 5749652 commit 16acb27

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tests/helpers/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from mavedb.models.enums.processing_state import ProcessingState
66

77
TEST_PUBMED_IDENTIFIER = "20711194"
8+
TEST_PUBMED_URL_IDENTIFIER = "https://pubmed.ncbi.nlm.nih.gov/37162834/"
89
TEST_BIORXIV_IDENTIFIER = "2021.06.21.212592"
910
TEST_MEDRXIV_IDENTIFIER = "2021.06.22.21259265"
1011
TEST_CROSSREF_IDENTIFIER = "10.1371/2021.06.22.21259265"

tests/routers/test_experiments.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
TEST_MINIMAL_EXPERIMENT_RESPONSE,
2727
TEST_ORCID_ID,
2828
TEST_PUBMED_IDENTIFIER,
29+
TEST_PUBMED_URL_IDENTIFIER,
2930
TEST_USER,
3031
)
3132
from tests.helpers.dependency_overrider import DependencyOverrider
@@ -712,6 +713,7 @@ def test_required_fields(client, setup_router_db, test_field):
712713
def test_create_experiment_with_new_primary_pubmed_publication(client, setup_router_db, mock_publication_fetch):
713714
mocked_publication = mock_publication_fetch
714715
response_data = create_experiment(client, {"primaryPublicationIdentifiers": [mocked_publication]})
716+
print(response_data)
715717

716718
assert len(response_data["primaryPublicationIdentifiers"]) == 1
717719
assert sorted(response_data["primaryPublicationIdentifiers"][0]) == sorted(
@@ -730,7 +732,37 @@ def test_create_experiment_with_new_primary_pubmed_publication(client, setup_rou
730732
"publicationYear",
731733
]
732734
)
733-
# TODO: add separate tests for generating the publication url and referenceHtml
735+
736+
737+
@pytest.mark.parametrize(
738+
"mock_publication_fetch",
739+
[({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_URL_IDENTIFIER}"})],
740+
indirect=["mock_publication_fetch"],
741+
)
742+
def test_create_experiment_with_new_primary_pubmed_url_publication(client, setup_router_db, mock_publication_fetch):
743+
mocked_publication = mock_publication_fetch
744+
response_data = create_experiment(client, {"primaryPublicationIdentifiers": [mocked_publication]})
745+
print(response_data)
746+
747+
assert len(response_data["primaryPublicationIdentifiers"]) == 1
748+
assert sorted(response_data["primaryPublicationIdentifiers"][0]) == sorted(
749+
[
750+
"abstract",
751+
"id",
752+
"authors",
753+
"dbName",
754+
"doi",
755+
"identifier",
756+
"title",
757+
"url",
758+
"recordType",
759+
"referenceHtml",
760+
"publicationJournal",
761+
"publicationYear",
762+
]
763+
)
764+
assert response_data["primaryPublicationIdentifiers"][0]["identifier"] == '37162834'
765+
734766

735767

736768
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)