Skip to content

Commit

Permalink
add test function for Clinical.preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
danlu1 committed Mar 16, 2024
1 parent 9a06b74 commit 05d8a86
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,33 @@ def table_query_results(*args):
)
)

patientdf = pd.DataFrame(
dict(
fieldName=["PATIENT_ID", "SEX", "PRIMARY_RACE"],
patient=[True, True, True],
sample=[True, False, False],
)
)
sampledf = pd.DataFrame(
dict(
fieldName=["PATIENT_ID", "SAMPLE_ID"],
patient=[True, False],
sample=[True, True],
)
)


table_query_results_map = {
("select * from syn7434222",): createMockTable(sexdf),
("select * from syn7434236",): createMockTable(no_nan),
("select * from syn7434242",): createMockTable(no_nan),
("select * from syn7434273",): createMockTable(no_nan),
(
"select fieldName from syn8545211 where patient is True and inClinicalDb is True",
): createMockTable(patientdf),
(
"select fieldName from syn8545211 where sample is True and inClinicalDb is True",
): createMockTable(sampledf),
}

json_oncotreeurl = (
Expand Down Expand Up @@ -1382,3 +1404,25 @@ def test_that__cross_validate_assay_info_has_seq_returns_expected_msg_if_valid(
)
assert warnings == expected_warning
assert errors == expected_error


def test_preprocess(clin_class, newpath=None):
expected = {
"clinicalTemplate": pd.DataFrame(
columns=["PATIENT_ID", "SEX", "PRIMARY_RACE", "SAMPLE_ID"]
),
"sample": True,
"patient": True,
"patientCols": ["PATIENT_ID", "SEX", "PRIMARY_RACE"],
"sampleCols": ["PATIENT_ID", "SAMPLE_ID"],
}
results = clin_class.preprocess(newpath)
assert (
results["clinicalTemplate"]
.sort_index(axis=1)
.equals(expected["clinicalTemplate"].sort_index(axis=1))
)
assert results["sample"] == expected["sample"]
assert results["patient"] == expected["patient"]
assert results["patientCols"] == expected["patientCols"]
assert results["sampleCols"] == expected["sampleCols"]

0 comments on commit 05d8a86

Please sign in to comment.