Skip to content

Commit

Permalink
test: update fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Apr 25, 2024
1 parent 8aada4d commit 95c63f4
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 60 deletions.
26 changes: 13 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ def pytest_configure(config):
logging.getLogger("urllib3.connectionpool").setLevel(logging.ERROR)


def _compare_records(normalized_gene, test_gene, match_type):
def _compare_records(normalized_gene, fixture_gene, match_type):
"""Check that normalized_gene and test_gene are the same."""
assert normalized_gene.match_type == match_type
assert normalized_gene.label == test_gene.label
assert normalized_gene.concept_id == test_gene.concept_id
assert set(normalized_gene.aliases) == set(test_gene.aliases)
assert set(normalized_gene.xrefs) == set(test_gene.xrefs)
assert normalized_gene.symbol_status == test_gene.symbol_status
assert set(normalized_gene.previous_symbols) == set(test_gene.previous_symbols)
assert normalized_gene.symbol == test_gene.symbol
assert len(normalized_gene.locations) == len(test_gene.locations)
assert normalized_gene.label == fixture_gene.label
assert normalized_gene.concept_id == fixture_gene.concept_id
assert set(normalized_gene.aliases) == set(fixture_gene.aliases)
assert set(normalized_gene.xrefs) == set(fixture_gene.xrefs)
assert normalized_gene.symbol_status == fixture_gene.symbol_status
assert set(normalized_gene.previous_symbols) == set(fixture_gene.previous_symbols)
assert normalized_gene.symbol == fixture_gene.symbol
assert len(normalized_gene.locations) == len(fixture_gene.locations)
for loc in normalized_gene.locations:
assert loc in test_gene.locations
assert loc in fixture_gene.locations
assert set(normalized_gene.location_annotations) == set(
test_gene.location_annotations
fixture_gene.location_annotations
)
assert normalized_gene.strand == test_gene.strand
assert normalized_gene.gene_type == test_gene.gene_type
assert normalized_gene.strand == fixture_gene.strand
assert normalized_gene.gene_type == fixture_gene.gene_type


@pytest.fixture(scope="session")
Expand Down
20 changes: 12 additions & 8 deletions tests/unit/test_ensembl_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ def search(self, query_str):
resp = self.query_handler.search(query_str, sources=[SourceName.ENSEMBL])
return resp.source_matches[SourceName.ENSEMBL]

e = QueryGetter()
return e
return QueryGetter()


@pytest.fixture(scope="module")
def ddx11l1():
"""Create a DDX11L1 fixutre."""
"""Create a DDX11L1 fixture."""
params = {
"match_type": MatchType.NO_MATCH,
"concept_id": "ensembl:ENSG00000223972",
Expand All @@ -36,14 +35,15 @@ def ddx11l1():
"location_annotations": [],
"locations": [
{
"id": "ga4gh:SL.Ihi0T86UoFIEbH0DHttX2nIw_BdOkI5L",
"id": "ga4gh:SL.cVhZkPm3Dtmqka5imaxIxA8NTOWkfjsB",
"end": 14409,
"start": 11868,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO",
},
"type": "SequenceLocation",
"digest": "cVhZkPm3Dtmqka5imaxIxA8NTOWkfjsB",
}
],
"strand": "+",
Expand All @@ -67,14 +67,15 @@ def tp53():
"location_annotations": [],
"locations": [
{
"id": "ga4gh:SL.TlGoA-JmP3Xky3RhJ6_UU3eJKq8EpEp9",
"id": "ga4gh:SL.fPR5aPzsxVW_vzQeiX7u4NLUopq35WQi",
"end": 7687538,
"start": 7661778,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.dLZ15tNO1Ur0IcGjwc3Sdi_0A6Yf4zm7",
},
"type": "SequenceLocation",
"digest": "fPR5aPzsxVW_vzQeiX7u4NLUopq35WQi",
}
],
"strand": "-",
Expand All @@ -98,14 +99,15 @@ def ATP6AP1_DT(): # noqa: N802
"location_annotations": [],
"locations": [
{
"id": "ga4gh:SL.bPbeeEGSqjlZJ1Ddmg5T9ptJz9tKxYi3",
"id": "ga4gh:SL.BtAK641MgbS9-8Mkbp_4b3cCkK_YzggB",
"end": 154428526,
"start": 154424377,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"type": "SequenceLocation",
"digest": "BtAK641MgbS9-8Mkbp_4b3cCkK_YzggB",
}
],
"strand": "-",
Expand All @@ -128,14 +130,15 @@ def hsa_mir_1253():
"location_annotations": [],
"locations": [
{
"id": "ga4gh:SL.x4kOE6ZXG-xY7nm6bu2W7lvm6ljaJXzR",
"id": "ga4gh:SL.FQOKjpXhjVgZvT3ldgmIuSrn2DMXiTvA",
"end": 2748182,
"start": 2748077,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.dLZ15tNO1Ur0IcGjwc3Sdi_0A6Yf4zm7",
},
"type": "SequenceLocation",
"digest": "FQOKjpXhjVgZvT3ldgmIuSrn2DMXiTvA",
}
],
"strand": "+",
Expand All @@ -160,14 +163,15 @@ def spry3():
"location_annotations": [],
"locations": [
{
"id": "ga4gh:SL.fxU7Axal2_GbyOfW8NQf0plM-SUWFCB0",
"id": "ga4gh:SL.KIwmMchAG4ApWxJUigdfUw2Y4wSdhsOd",
"end": 155782459,
"start": 155612571,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"type": "SequenceLocation",
"digest": "KIwmMchAG4ApWxJUigdfUw2Y4wSdhsOd",
}
],
"strand": "+",
Expand Down
43 changes: 28 additions & 15 deletions tests/unit/test_ncbi_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test import of NCBI source data"""
from datetime import datetime
import datetime

import pytest

Expand Down Expand Up @@ -36,8 +36,7 @@ def search(self, query_str):
resp = self.query_handler.search(query_str, sources=[SourceName.NCBI])
return resp.source_matches[SourceName.NCBI]

n = QueryGetter()
return n
return QueryGetter()


@pytest.fixture(scope="module")
Expand All @@ -64,14 +63,15 @@ def dpf1():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.0bmpLh_dlBRrzfviiQY9Vg4iEH0XeR20",
"id": "ga4gh:SL.rR9fASAGEC1fxbe2CoU_QywsIN502R78",
"end": 38229695,
"start": 38211005,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.IIB53T8CNeJJdUqzn9V_JnRtQadwWCbl",
},
"type": "SequenceLocation",
"digest": "rR9fASAGEC1fxbe2CoU_QywsIN502R78",
}
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -103,14 +103,15 @@ def pdp1_symbol():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.-455M-S51D8nXPFoGH0dYNFVFAJxm5dG",
"id": "ga4gh:SL.JJ4cz7_OuxFZQ7i1J4c4NbyLd0M74fCA",
"end": 93926068,
"start": 93916922,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.209Z7zJ-mFypBEWLk4rNC6S_OxY5p7bs",
},
"type": "SequenceLocation",
"digest": "JJ4cz7_OuxFZQ7i1J4c4NbyLd0M74fCA",
}
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -142,14 +143,15 @@ def pdp1_alias():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.VI_0P0-ei90MDsLjAeUrDfeXBlZVJtJY",
"id": "ga4gh:SL.6JIWLg48NzkU5TuMrHJ3TlFS1QKYmQ2W",
"end": 4665258,
"start": 4662293,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.KEO-4XBcm1cxeo_DIQ8_ofqGUkp4iZhI",
},
"type": "SequenceLocation",
"digest": "6JIWLg48NzkU5TuMrHJ3TlFS1QKYmQ2W",
}
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -190,24 +192,26 @@ def spry3():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.2N5aguRIvBdGemRgABZFutmLTV925dsV",
"id": "ga4gh:SL.wn-2JhwdvKqHLW3fuP3w_HgMstxBgfDj",
"end": 155782459,
"start": 155612585,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"type": "SequenceLocation",
"digest": "wn-2JhwdvKqHLW3fuP3w_HgMstxBgfDj",
},
{
"id": "ga4gh:SL.U9E9WtQdzFc4elR3t1qw48nueHgfWFWL",
"id": "ga4gh:SL.tfIWUCWL9N99vBw_HhBLu5G-XJ_nf2wW",
"end": 56968979,
"start": 56954315,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5",
},
"type": "SequenceLocation",
"digest": "tfIWUCWL9N99vBw_HhBLu5G-XJ_nf2wW",
},
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -282,14 +286,15 @@ def znf84():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.IRsls9vud2-CiA7Jq4L3ry2VVK7LoNud",
"id": "ga4gh:SL.iVZ8b-X1k7egMDYe_FPSTUwyzJEWQWXB",
"end": 133063299,
"start": 133037508,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.6wlJpONE3oNb4D69ULmEXhqyDZ4vwNfl",
},
"type": "SequenceLocation",
"digest": "iVZ8b-X1k7egMDYe_FPSTUwyzJEWQWXB",
}
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -336,24 +341,26 @@ def slc25a6():
# "end": "p11.2"
# },
{
"id": "ga4gh:SL.dvD-ZopQGZkVWx4Z-vFpP9ateicPHgQ6",
"id": "ga4gh:SL._eLXsn_yz0kSJAl7QH42n4wE3Fy57z2P",
"type": "SequenceLocation",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.w0WZEvgJF0zf_P4yyTzjjv9oW1z61HHP",
},
"start": 1386151,
"end": 1392113,
"digest": "_eLXsn_yz0kSJAl7QH42n4wE3Fy57z2P",
},
{
"id": "ga4gh:SL.bv3LobZZ-sERq5cIthyS4w_tmSwV2QSg",
"id": "ga4gh:SL.qoi_lciuVRoZjmT5_oZ28LOHICPER1a4",
"type": "SequenceLocation",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5",
},
"start": 1386151,
"end": 1392113,
"digest": "qoi_lciuVRoZjmT5_oZ28LOHICPER1a4",
},
],
"gene_type": "protein-coding",
Expand Down Expand Up @@ -477,24 +484,26 @@ def prkrap1():
# "type": "ChromosomeLocation"
# },
{
"id": "ga4gh:SL.LwWy5JYncZVnOM9hWiLWW_z0n2eY-peb",
"id": "ga4gh:SL.1wklqN-Yvbdsx5m5XV7JuoaYS-Gl94cx",
"end": 3941874,
"start": 3940269,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.MjujHSAsgNWRTX4w3ysM7b5OVhZpdXu1",
},
"type": "SequenceLocation",
"digest": "1wklqN-Yvbdsx5m5XV7JuoaYS-Gl94cx",
},
{
"id": "ga4gh:SL.q36ql_fX4HrZy_G2EXX_SGWl-7X5Bq6c",
"id": "ga4gh:SL.k-GoObtGSBDvWeu5gYWUca1osgbJpGib",
"end": 3932085,
"start": 3930480,
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.Q8IworEhpLeXwpz1CHM7C3luysh-ltx-",
},
"type": "SequenceLocation",
"digest": "k-GoObtGSBDvWeu5gYWUca1osgbJpGib",
},
],
"gene_type": "pseudo",
Expand Down Expand Up @@ -848,7 +857,9 @@ def test_no_match(ncbi, source_urls):
response.source_meta_.data_license_url
== "https://www.ncbi.nlm.nih.gov/home/about/policies/"
)
assert datetime.strptime(response.source_meta_.version, "%Y%m%d")
assert datetime.datetime.strptime(response.source_meta_.version, "%Y%m%d").replace(
tzinfo=datetime.timezone.utc
)
assert response.source_meta_.data_url == source_urls
assert response.source_meta_.rdp_url == "https://reusabledata.org/ncbi-gene.html"
assert response.source_meta_.data_license_attributes.non_commercial is False
Expand Down Expand Up @@ -894,7 +905,9 @@ def test_meta(ncbi, source_urls):
response.source_meta_.data_license_url
== "https://www.ncbi.nlm.nih.gov/home/about/policies/"
)
assert datetime.strptime(response.source_meta_.version, "%Y%m%d")
assert datetime.datetime.strptime(response.source_meta_.version, "%Y%m%d").replace(
tzinfo=datetime.timezone.utc
)
assert response.source_meta_.data_url == source_urls
assert response.source_meta_.rdp_url == "https://reusabledata.org/ncbi-gene.html"
assert response.source_meta_.genome_assemblies == ["GRCh38.p14"]
Expand Down
Loading

0 comments on commit 95c63f4

Please sign in to comment.