Ejemplo n.º 1
0
def test_search_measures_by_keyword_in_instrument_name(
    fake_phenotype_data_browser_dir, ):
    db = DbManager(fake_phenotype_data_browser_dir)
    assert db is not None
    db.build()

    measure_df = db.search_measures_df(None, "i")
    assert len(measure_df) == 15

    measure_df = db.search_measures_df(None, "i1")
    assert len(measure_df) == 12
    for _, row in measure_df.iterrows():
        assert row["instrument_name"] == "i1"
Ejemplo n.º 2
0
def test_search_measures_get_by_instrument(fake_phenotype_data_browser_dir):
    db = DbManager(fake_phenotype_data_browser_dir)
    assert db is not None
    db.build()
    measure_df = db.search_measures_df("i1", None)
    assert len(measure_df) == 12
    for _, row in measure_df.iterrows():
        assert row["instrument_name"] == "i1"

    measure_df = db.search_measures_df("i2", None)
    assert len(measure_df) == 3
    print(measure_df)
    for _, row in measure_df.iterrows():
        assert row["instrument_name"] == "i2"
Ejemplo n.º 3
0
def test_search_measures_by_keyword_in_measure_id(
    fake_phenotype_data_browser_dir, ):
    db = DbManager(fake_phenotype_data_browser_dir)
    assert db is not None
    db.build()
    measure_df = db.search_measures_df(None, "i1.m2")
    assert len(measure_df) == 1
    assert measure_df.iloc[0]["measure_name"] == "m2"
    assert measure_df.iloc[0]["instrument_name"] == "i1"
Ejemplo n.º 4
0
def test_search_measures_by_keyword_in_description(
    fake_phenotype_data_browser_dir, ):
    db = DbManager(fake_phenotype_data_browser_dir)
    assert db is not None
    db.build()
    measure_df = db.search_measures_df(None, "number")
    assert len(measure_df) == 3
    for _, row in measure_df.iterrows():
        assert "number" in row["description"]
Ejemplo n.º 5
0
def test_db_search_character_escaping(output_dir):
    db = DbManager(os.path.join(output_dir, "temp_testing.db"))
    assert db is not None
    db.build()

    v = {
        "measure_id": "test_one.measure1",
        "instrument_name": "test_one",
        "measure_name": "measure1",
        "measure_type": "other",
        "description": "desc",
    }

    v2 = {
        "measure_id": "test%two.measure2",
        "instrument_name": "test%two",
        "measure_name": "measure2",
        "measure_type": "other",
        "description": "desc",
    }

    db.save(v)
    db.save(v2)

    r = db.search_measures_df(keyword="test_one")
    assert r is not None
    assert len(r) == 1
    assert r["measure_id"][0] == "test_one.measure1"
    assert r["instrument_name"][0] == "test_one"
    assert r["measure_name"][0] == "measure1"

    r = db.search_measures_df(keyword="test%two")
    assert r is not None
    assert len(r) == 1
    assert r["measure_id"][0] == "test%two.measure2"
    assert r["instrument_name"][0] == "test%two"
    assert r["measure_name"][0] == "measure2"