Example #1
0
def test_create_portal_query_for_outliers() -> None:
    test_df = pd.DataFrame({
        CSV_INSTITUTION_HEADER: range(2),
        CSV_SERIES_HEADER: range(3, 5),
        "other": range(2)
    })
    expected = PORTAL_QUERY_TEMPLATE.format('r.InstitutionId = "0" OR r.InstitutionId = "1"',
                                            'STARTSWITH(r.VersionedDicomImageSeries.Latest.Series.InstanceUID,"3") OR '
                                            'STARTSWITH(r.VersionedDicomImageSeries.Latest.Series.InstanceUID,"4")')

    assert expected == create_portal_query_for_outliers(test_df)
Example #2
0
def test_create_portal_query_for_outliers() -> None:
    test_df = pd.DataFrame({
        CSV_INSTITUTION_HEADER: range(2),
        CSV_SERIES_HEADER: range(3, 5),
        "other": range(2)
    })
    expected = PORTAL_QUERY_TEMPLATE.format(
        'r.InstitutionId = "0" OR r.InstitutionId = "1"',
        'STARTSWITH(r.VersionedDicomImageSeries.Latest.Series.InstanceUID,"3") OR '
        'STARTSWITH(r.VersionedDicomImageSeries.Latest.Series.InstanceUID,"4")'
    )
    assert expected == create_portal_query_for_outliers(test_df)
    with raises(ValueError) as institution_column_missing_error:
        test_df_pruned = test_df.drop(columns=[CSV_INSTITUTION_HEADER])
        create_portal_query_for_outliers(test_df_pruned)
        error_message = str(institution_column_missing_error.value)
        assert CSV_INSTITUTION_HEADER in error_message
    with raises(ValueError) as series_column_missing_error:
        test_df_pruned = test_df.drop(columns=[CSV_SERIES_HEADER])
        create_portal_query_for_outliers(test_df_pruned)
        error_message = str(series_column_missing_error.value)
        assert CSV_SERIES_HEADER in error_message