Skip to content

Commit aa620b0

Browse files
committed
docs + rename
1 parent d2fe4b4 commit aa620b0

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

tests/unit/anyvar/test_clients.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
@pytest.fixture(scope="session")
2222
def anyvar_postgres_uri():
23+
"""Create test fixure for AnyVar postgres storage URI"""
2324
uri = os.environ.get(
2425
"ANYVLM_ANYVAR_TEST_STORAGE_URI",
2526
"postgresql://postgres:postgres@localhost:5432/anyvlm_anyvar_test",
@@ -29,6 +30,7 @@ def anyvar_postgres_uri():
2930

3031
@pytest.fixture
3132
def anyvar_python_client(anyvar_postgres_uri: str) -> PythonAnyVarClient:
33+
"""Create test fixture for AnyVar Python Client"""
3234
storage = create_storage(anyvar_postgres_uri)
3335
storage.wipe_db()
3436
translator = create_translator()
@@ -37,20 +39,23 @@ def anyvar_python_client(anyvar_postgres_uri: str) -> PythonAnyVarClient:
3739

3840
@pytest.fixture
3941
def anyvar_http_client() -> HttpAnyVarClient:
42+
"""Create test fixture for AnyVar HTTP client"""
4043
return HttpAnyVarClient()
4144

4245

4346
@pytest.fixture
4447
def anyvar_populated_python_client(
4548
anyvar_python_client: PythonAnyVarClient, alleles: dict
4649
):
50+
"""Create test fixture for populated AnyVar Python client"""
4751
for allele_fixture in alleles.values():
4852
anyvar_python_client.put_objects([models.Allele(**allele_fixture["variation"])])
4953
return anyvar_python_client
5054

5155

5256
@pytest.fixture
5357
def client(request):
58+
"""Create test fixture for AnyVar Python or HTTP client"""
5459
return request.getfixturevalue(request.param)
5560

5661

@@ -66,31 +71,31 @@ def client(request):
6671

6772

6873
@pytest.mark.vcr
69-
@pytest.mark.parametrize("client", UNPOPULATED_CLIENTS, indirect=True)
70-
def test_put_objects(client: BaseAnyVarClient, alleles: dict):
74+
@pytest.mark.parametrize("anyvar_client", UNPOPULATED_CLIENTS, indirect=True)
75+
def test_put_objects(anyvar_client: BaseAnyVarClient, alleles: dict):
7176
"""Test `put_objects` for a basic test suite of variants"""
7277
for allele_fixture in alleles.values():
7378
allele = models.Allele(**allele_fixture["variation"])
74-
client.put_objects([allele])
79+
anyvar_client.put_objects([allele])
7580

7681

7782
@pytest.mark.vcr
78-
@pytest.mark.parametrize("client", UNPOPULATED_CLIENTS, indirect=True)
79-
def test_put_objects_no_ids(client: BaseAnyVarClient, alleles: dict):
83+
@pytest.mark.parametrize("anyvar_client", UNPOPULATED_CLIENTS, indirect=True)
84+
def test_put_objects_no_ids(anyvar_client: BaseAnyVarClient, alleles: dict):
8085
"""Test `put_objects` for objects with IDs/digest/etc removed"""
8186
allele_iter = iter(alleles.values())
8287
allele = models.Allele(**next(allele_iter)["variation"])
8388
allele.id = None
8489
other_allele = models.Allele(**next(allele_iter)["variation"])
8590
with pytest.raises(UnidentifiedObjectError):
86-
client.put_objects([other_allele, allele])
91+
anyvar_client.put_objects([other_allele, allele])
8792

8893

8994
@pytest.mark.vcr
90-
@pytest.mark.parametrize("client", POPULATED_CLIENTS, indirect=True)
91-
def test_search_by_interval(client: BaseAnyVarClient, alleles: dict):
95+
@pytest.mark.parametrize("anyvar_client", POPULATED_CLIENTS, indirect=True)
96+
def test_search_by_interval(anyvar_client: BaseAnyVarClient, alleles: dict):
9297
"""Test `search_by_interval` for a couple of basic cases"""
93-
results = client.search_by_interval(
98+
results = anyvar_client.search_by_interval(
9499
"ga4gh:SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5", 2781760, 2781760
95100
)
96101
assert sorted(results, key=lambda r: r.id) == [
@@ -104,7 +109,7 @@ def test_search_by_interval(client: BaseAnyVarClient, alleles: dict):
104109
**alleles["ga4gh:VA.xbX035HgURWIUAjn6x3cS26jafP8Q_bk"]["variation"]
105110
),
106111
]
107-
results = client.search_by_interval(
112+
results = anyvar_client.search_by_interval(
108113
"ga4gh:SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5", 2781760, 2781768
109114
)
110115
assert sorted(results, key=lambda r: r.id) == [
@@ -124,10 +129,10 @@ def test_search_by_interval(client: BaseAnyVarClient, alleles: dict):
124129

125130

126131
@pytest.mark.vcr
127-
@pytest.mark.parametrize("client", POPULATED_CLIENTS, indirect=True)
128-
def test_search_by_interval_with_alias(client: BaseAnyVarClient, alleles: dict):
132+
@pytest.mark.parametrize("anyvar_client", POPULATED_CLIENTS, indirect=True)
133+
def test_search_by_interval_with_alias(anyvar_client: BaseAnyVarClient, alleles: dict):
129134
"""Test use of sequence alias"""
130-
results = client.search_by_interval("GRCh38.p1:Y", 2781760, 2781760)
135+
results = anyvar_client.search_by_interval("GRCh38.p1:Y", 2781760, 2781760)
131136
assert sorted(results, key=lambda r: r.id) == [
132137
models.Allele(
133138
**alleles["ga4gh:VA.9VDxL0stMBOZwcTKw3yb3UoWQkpaI9OD"]["variation"]
@@ -142,27 +147,27 @@ def test_search_by_interval_with_alias(client: BaseAnyVarClient, alleles: dict):
142147

143148

144149
@pytest.mark.vcr
145-
@pytest.mark.parametrize("client", POPULATED_CLIENTS, indirect=True)
146-
def test_search_by_interval_unknown_alias(client: BaseAnyVarClient):
150+
@pytest.mark.parametrize("anyvar_client", POPULATED_CLIENTS, indirect=True)
151+
def test_search_by_interval_unknown_alias(anyvar_client: BaseAnyVarClient):
147152
"""Test handling response when sequence alias isn't recognized."""
148-
assert client.search_by_interval("GRCh45.p1:Y", 2781760, 2781760) == []
153+
assert anyvar_client.search_by_interval("GRCh45.p1:Y", 2781760, 2781760) == []
149154

150155

151156
@pytest.mark.vcr
152-
@pytest.mark.parametrize("client", POPULATED_CLIENTS, indirect=True)
153-
def test_search_by_interval_unknown_accession(client: BaseAnyVarClient):
157+
@pytest.mark.parametrize("anyvar_client", POPULATED_CLIENTS, indirect=True)
158+
def test_search_by_interval_unknown_accession(anyvar_client: BaseAnyVarClient):
154159
"""Test handling response when accession ID isn't recognized"""
155-
results = client.search_by_interval(
160+
results = anyvar_client.search_by_interval(
156161
"ga4gh:SQ.ZZZZZu1aycC0tPQPFmUaGXJLDs5SbPZ5", 2781760, 2781768
157162
)
158163
assert results == []
159164

160165

161166
@pytest.mark.vcr
162-
@pytest.mark.parametrize("client", POPULATED_CLIENTS, indirect=True)
163-
def test_search_by_interval_not_found(client: BaseAnyVarClient):
167+
@pytest.mark.parametrize("anyvar_client", POPULATED_CLIENTS, indirect=True)
168+
def test_search_by_interval_not_found(anyvar_client: BaseAnyVarClient):
164169
"""Test handling response when no matching variants are found"""
165-
results = client.search_by_interval(
170+
results = anyvar_client.search_by_interval(
166171
"ga4gh:SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5", 1, 100
167172
)
168173
assert results == []

0 commit comments

Comments
 (0)