def test_basic_drift_detection():
    """
    Tests that drift detection works.
    """
    data = FileSystem.load("tests/data/test_cli_detectors/detector/1.json")
    start_state = StateSchema().load(data)
    data = FileSystem.load("tests/data/test_cli_detectors/detector/2.json")
    end_state = StateSchema().load(data)
    new_results, missing_results = perform_drift_detection(
        start_state, end_state)
    new_results = [
        drift_info_detector_pair[0] for drift_info_detector_pair in new_results
    ]
    missing_results = [
        drift_info_detector_pair[0]
        for drift_info_detector_pair in missing_results
    ]
    assert {
        'd.test': '36',
        'd.test2': '37',
        'd.test3': ['38', '39', '40']
    } in new_results
    assert {
        'd.test': '7',
        'd.test2': '14',
        'd.test3': ['21', '28', '35']
    } in missing_results
示例#2
0
def test_basic_drift_detection():
    """
    Tests that drift detection works.
    """
    data = FileSystem.load("tests/data/test_cli_detectors/detector/1.json")
    start_state = StateSchema().load(data)
    data = FileSystem.load("tests/data/test_cli_detectors/detector/2.json")
    end_state = StateSchema().load(data)
    new_results, missing_results = perform_drift_detection(start_state, end_state)
    assert ['36', '37', ['38', '39', '40']] in new_results
    assert ['7', '14', ['21', '28', '35']] in missing_results
示例#3
0
def test_compare_states():
    """
    Test that differences between two states is recorded
    :return:
    """

    filepath = "tests/data/detectors/test_expectations.json"
    data = FileSystem.load(filepath)
    state_1 = StateSchema().load(data)
    state_2 = StateSchema().load(data)
    state_1.results.append(["7"])
    state_2.results.append(["8"])
    new, missing = perform_drift_detection(state_1, state_2)
    assert ({'d.test': "7"}, state_1) in missing
    assert ({'d.test': "8"}, state_2) in new
def test_drift_detection_errors():
    data = FileSystem.load("tests/data/test_cli_detectors/detector/1.json")
    start_state = StateSchema().load(data)
    data = FileSystem.load("tests/data/test_cli_detectors/detector/2.json")
    end_state = StateSchema().load(data)

    start_state.name = "Wrong Name"
    with pytest.raises(ValueError):
        perform_drift_detection(start_state, end_state)

    start_state = StateSchema().load(data)
    start_state.properties = ["Incorrect", "Properties"]
    with pytest.raises(ValueError):
        perform_drift_detection(start_state, end_state)

    start_state = StateSchema().load(data)
    start_state.validation_query = "Invalid Validation Query"
    with pytest.raises(ValueError):
        perform_drift_detection(start_state, end_state)