Skip to content

Commit

Permalink
fixed tests for new spec
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Oct 26, 2023
1 parent 6a444e8 commit a1fbcbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def test_data_bed():
@pytest.fixture
def test_data_bedset():
s = "test_string"
return {"name": s, "bedset_tar_archive_path": {"path": s, "title": s}}
return {"name": s, "bedset_means": {
"exon_frequency": 271,
"exon_percentage": 0.081,}}


@pytest.fixture
Expand Down
1 change: 1 addition & 0 deletions tests/data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ path:
bedstat_dir: bedstat_output
bedbuncher_dir: bedbuncher_output
remote_url_base: null
region2vec: "add/path/here"
server:
host: 0.0.0.0
port: 8000
Expand Down
29 changes: 6 additions & 23 deletions tests/test_bbconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,17 @@ def test_reporting_relationships(self, cfg_pth, test_data_bed, test_data_bedset)
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
record_identifier="bedset1", result_identifier="id"
)
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
print("a")
bbc.report_relationship(bedfile_record_id="bed1", bedset_record_id="bedset1")

def test_cant_remove_record_if_in_reltable(
self, cfg_pth, test_data_bed, test_data_bedset
):
with ContextManagerDBTesting(DB_URL):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
record_identifier="bedset1", result_identifier="id"
)
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
bbc.report_relationship(bedfile_record_id="bed1", bedset_record_id="bedset1")
with pytest.raises(IntegrityError):
bbc.bed.remove(record_identifier="bed1")
with pytest.raises(IntegrityError):
Expand All @@ -103,11 +94,7 @@ def test_select(self, cfg_pth, test_data_bed, test_data_bedset):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
record_identifier="bedset1", result_identifier="id"
)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
bbc.report_relationship(bedfile_record_id="bed1", bedset_record_id="bedset1")

unique_bedfiles = bbc.select_unique(table_name="bedfile__sample")
assert unique_bedfiles[0].record_identifier == "bed1"
Expand All @@ -121,12 +108,8 @@ def test_removal(self, cfg_pth, test_data_bed, test_data_bedset):
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))
bbc.bed.report(record_identifier="bed1", values=test_data_bed)
bbc.bedset.report(record_identifier="bedset1", values=test_data_bedset)
bedset_id = bbc.bedset.retrieve(
record_identifier="bedset1", result_identifier="id"
)
bed_id = bbc.bed.retrieve(record_identifier="bed1", result_identifier="id")
bbc.report_relationship(bedfile_id=bed_id, bedset_id=bedset_id)
bbc.remove_relationship(bedset_id=bedset_id, bedfile_ids=[bed_id])
bbc.report_relationship(bedfile_record_id="bed1", bedset_record_id="bedset1",)
bbc.remove_relationship(bedset_record_id="bedset1", bedfile_record_id=["bed1"])
ori_cnt = bbc.bed.record_count
bbc.bed.remove(record_identifier="bed1")
assert ori_cnt - 1 == bbc.bed.record_count
Expand All @@ -139,6 +122,6 @@ def test_config_variables_are_set(self, cfg_pth, test_data_bed, test_data_bedset
bbc = BedBaseConf(get_bedbase_cfg(cfg=cfg_pth))

print(bbc.config["qdrant"]["host"])
assert bbc.config["qdrant"]["host"] == "test_localhost"
assert bbc.config["qdrant"]["host"] == "localhost"
assert bbc.config["path"]["region2vec"] is not None
assert bbc.config["database"]["host"] in ["localhost", "127.0.0.1"]

0 comments on commit a1fbcbd

Please sign in to comment.