Skip to content

Commit c267ede

Browse files
authored
Merge pull request #387 from VariantEffect/estelle/addPublicationIdentifierTests
Add a PubMed url test.
2 parents 5749652 + 5ad83b1 commit c267ede

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-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: 30 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
@@ -730,7 +731,35 @@ def test_create_experiment_with_new_primary_pubmed_publication(client, setup_rou
730731
"publicationYear",
731732
]
732733
)
733-
# TODO: add separate tests for generating the publication url and referenceHtml
734+
735+
736+
@pytest.mark.parametrize(
737+
"mock_publication_fetch",
738+
[({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_URL_IDENTIFIER}"})],
739+
indirect=["mock_publication_fetch"],
740+
)
741+
def test_create_experiment_with_new_primary_pubmed_url_publication(client, setup_router_db, mock_publication_fetch):
742+
mocked_publication = mock_publication_fetch
743+
response_data = create_experiment(client, {"primaryPublicationIdentifiers": [mocked_publication]})
744+
745+
assert len(response_data["primaryPublicationIdentifiers"]) == 1
746+
assert sorted(response_data["primaryPublicationIdentifiers"][0]) == sorted(
747+
[
748+
"abstract",
749+
"id",
750+
"authors",
751+
"dbName",
752+
"doi",
753+
"identifier",
754+
"title",
755+
"url",
756+
"recordType",
757+
"referenceHtml",
758+
"publicationJournal",
759+
"publicationYear",
760+
]
761+
)
762+
assert response_data["primaryPublicationIdentifiers"][0]["identifier"] == '37162834'
734763

735764

736765
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)