예제 #1
0
def test_only_encrypt_data(compute_backend_pii_df):
    sensitivewidget = sensitive_data(compute_backend_pii_df,
                                     mode="encrypt",
                                     detect_infotypes=False)
    assert isinstance(sensitivewidget, SensitiveDataWidget)
    assert _is_dataframe(sensitivewidget.encrypt)
    assert isinstance(sensitivewidget.encrypt["name"][1], str)
    assert isinstance(sensitivewidget.encrypt["domain"][1], str)
    assert isinstance(sensitivewidget.redact, type(None))
    assert isinstance(sensitivewidget.infotypes, type(None))
예제 #2
0
def test_sensitive_data_cols(compute_backend_pii_df):
    sensitivewidget = sensitive_data(compute_backend_pii_df,
                                     mode="redact",
                                     columns=["name"],
                                     detect_infotypes=False)
    assert isinstance(sensitivewidget, SensitiveDataWidget)
    assert _is_dataframe(sensitivewidget.redact)
    assert sensitivewidget.redact.shape == (1, 1)
    assert isinstance(sensitivewidget.infotypes, type(None))
    assert isinstance(sensitivewidget.encrypt, type(None))
예제 #3
0
def test_only_redact_data(compute_backend_pii_df):
    sensitivewidget = sensitive_data(compute_backend_pii_df,
                                     mode="redact",
                                     detect_infotypes=False)
    assert isinstance(sensitivewidget, SensitiveDataWidget)
    assert sensitivewidget.redact.shape == (1, 2)
    assert _is_dataframe(sensitivewidget.redact)
    assert sensitivewidget.redact["name"][1] == "<PERSON>"
    assert sensitivewidget.redact["domain"][1] == "<DOMAIN_NAME>"
    assert isinstance(sensitivewidget.redact["name"][1], str)
    assert isinstance(sensitivewidget.redact["domain"][1], str)
    assert isinstance(sensitivewidget.encrypt, type(None))
    assert isinstance(sensitivewidget.infotypes, type(None))
예제 #4
0
def test_encrypt_data_and_infotypes(compute_backend_pii_df):
    sensitivewidget = sensitive_data(compute_backend_pii_df,
                                     mode="encrypt",
                                     detect_infotypes=True,
                                     sample_size=1)
    assert isinstance(sensitivewidget.encrypt["name"][1], str)
    assert isinstance(sensitivewidget.encrypt["domain"][1], str)
    assert isinstance(sensitivewidget.infotypes, dict)
    assert sensitivewidget.infotypes["domain"][0] == "DOMAIN_NAME"
    assert sensitivewidget.infotypes["name"][0] == "PERSON"
    assert len(sensitivewidget.infotypes) == 2
    assert isinstance(sensitivewidget.redact, type(None))
    assert _is_dataframe(sensitivewidget.show())
예제 #5
0
def test_sample_size(compute_backend_pii_df):
    with pytest.raises(ValueError):
        sensitive_data(compute_backend_pii_df,
                       mode=None,
                       detect_infotypes=True,
                       sample_size=9)
예제 #6
0
def test_mode_value(compute_backend_pii_df):
    with pytest.raises(ValueError):
        sensitive_data(compute_backend_pii_df, mode="invalid mode")
예제 #7
0
def test_column_type(compute_backend_pii_df):
    with pytest.raises(TypeError):
        sensitive_data(compute_backend_pii_df, columns="this is not a list")
예제 #8
0
def test_type_df_type(compute_backend_pii_text):
    with pytest.raises(ValueError):
        sensitive_data(compute_backend_pii_text)