Skip to content

Commit ccfa8a2

Browse files
committed
Revert "add composite key + update tests"
This reverts commit b243519.
1 parent b243519 commit ccfa8a2

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

src/anyvlm/storage/orm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def __tablename__(self) -> str:
4242
return "allele_frequency_data"
4343

4444
vrs_id: Mapped[str] = mapped_column(String, primary_key=True)
45-
consequence: Mapped[str] = mapped_column(String, primary_key=True)
4645
af: Mapped[float] = mapped_column(Float)
4746
ac: Mapped[int] = mapped_column(Integer)
4847
an: Mapped[int] = mapped_column(Integer)
4948
ac_het: Mapped[int] = mapped_column(Integer)
5049
ac_hom: Mapped[int] = mapped_column(Integer)
5150
ac_hemi: Mapped[int] = mapped_column(Integer)
51+
consequence: Mapped[str] = mapped_column(String)
5252
filter: Mapped[list[str]] = mapped_column(ARRAY(String))
5353

5454

tests/unit/storage/test_postgres_unit.py

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from ga4gh.vrs.models import Allele, LiteralSequenceExpression
77
from tests.conftest import return_cafs
88

9-
from anyvlm.storage import orm
109
from anyvlm.storage.postgres import PostgresObjectStore
1110

1211

@@ -30,43 +29,27 @@ def test_add_allele_frequency(
3029
request, caf_fixture_name: str, postgres_storage: PostgresObjectStore
3130
):
3231
"""Test that add_allele_frequency method works correctly"""
32+
caf = request.getfixturevalue(caf_fixture_name)
33+
34+
def insert_and_verify_one_row():
35+
postgres_storage.add_allele_frequency(caf)
36+
37+
rows = return_cafs(postgres_storage)
38+
assert len(rows) == 1
39+
40+
db_record = rows[0]
3341

34-
def verify_row(db_record: orm.AlleleFrequencyData, expected_consequence: str):
35-
"""Verify row"""
3642
assert db_record.vrs_id == "ga4gh:VA.J3Hi64dkKFKdnKIwB2419Qz3STDB2sJq"
3743
assert db_record.af == 0.000162232
3844
assert db_record.ac == 1
3945
assert db_record.an == 6164
4046
assert db_record.ac_het == 1
4147
assert db_record.ac_hom == 0
42-
assert db_record.consequence == expected_consequence
48+
assert db_record.consequence == "intron_variant"
4349
assert db_record.filter == ["LowQual", "NO_HQ_GENOTYPES"]
4450

45-
def insert_and_verify_rows(
46-
caf_obj: CohortAlleleFrequencyStudyResult, expected_consequences: list[str]
47-
):
48-
"""Insert caf record and verify rows"""
49-
postgres_storage.add_allele_frequency(caf_obj)
50-
51-
rows = return_cafs(postgres_storage)
52-
assert len(rows) == len(expected_consequences)
53-
54-
for index, consequence in enumerate(expected_consequences):
55-
db_record = rows[index]
56-
verify_row(db_record, consequence)
57-
58-
caf = request.getfixturevalue(caf_fixture_name)
59-
expected_consequences = ["intron_variant"]
60-
6151
# first insert
62-
insert_and_verify_rows(caf, expected_consequences=expected_consequences)
52+
insert_and_verify_one_row()
6353

6454
# second insert
65-
insert_and_verify_rows(caf, expected_consequences=expected_consequences)
66-
67-
# test composite key
68-
new_caf = caf.model_copy(deep=True)
69-
new_consequence = "missense_variant"
70-
new_caf.ancillaryResults["consequence"] = new_consequence
71-
expected_consequences.append(new_consequence)
72-
insert_and_verify_rows(new_caf, expected_consequences=expected_consequences)
55+
insert_and_verify_one_row()

0 commit comments

Comments
 (0)