Skip to content

Commit

Permalink
tests: Add tests to preview_domain()
Browse files Browse the repository at this point in the history
  • Loading branch information
roquelopez committed Nov 25, 2024
1 parent 08f3033 commit a131caa
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,39 @@ def test_top_value_matches():
assert "source" in df_match.columns
assert "target" in df_match.columns
assert "similarity" in df_match.columns

def test_preview_domain():
# given
source = pd.DataFrame(
{
"name": ["John Doe", "Jane Doe", "Alice Smith", "Bob Smith"],
"age": [30, 25, 45, 35],
}
)

# when
preview = bdi.preview_domain(source, "age")

# then
# preview must contain only the column "value_name" and the unique
# values of the column "age"
assert preview is not None
assert isinstance(preview, pd.DataFrame)
assert "value_name" in preview.columns
assert "column_description" not in preview.columns
assert "value_description" not in preview.columns
assert source["age"].eq(preview["value_name"]).all()

# when
preview = bdi.preview_domain("gdc", "age_at_diagnosis")

# then
# preview must contain only the column "column_description" since there
# are sample values in the GDC dictionary
assert preview is not None
assert isinstance(preview, pd.DataFrame)
assert "value_name" not in preview.columns
assert "value_description" not in preview.columns
assert "column_description" in preview.columns


0 comments on commit a131caa

Please sign in to comment.