Beispiel #1
0
def test_run_asserts_series_one_host_multiple_asserts(run_asserts_mock: Mock):
    run_asserts_mock.return_value = {
        "A":
        [AssertResult(passed=True, actual="", expected="", description="")],
        "B":
        [AssertResult(passed=False, actual="", expected="", description="")],
    }

    test_state = defaultdict(dict)
    test_asserts = [
        {
            "name": "A",
            "type": "SQLAssert"
        },
        {
            "name": "B",
            "type": "SQLAssert"
        },
    ]

    results = testing.run_asserts_series(
        asserts=test_asserts,
        state=test_state,
        test_name="foo",
        hostnames=["alpha"],
        seconds_between_asserts=0,
    )

    assert results == {
        "A":
        [AssertResult(passed=True, actual="", expected="", description="")],
        "B":
        [AssertResult(passed=False, actual="", expected="", description="")],
    }
Beispiel #2
0
def test_run_asserts_series_multiple_host_multiple_asserts(
        run_asserts_mock: Mock):
    run_asserts_mock.side_effect = [{"A": [True]}, {"B": [False]}]

    test_state = defaultdict(dict)
    test_asserts = [
        {
            "name": "A",
            "type": "SQLAssert"
        },
        {
            "name": "B",
            "type": "SQLAssert"
        },
    ]

    results = testing.run_asserts_series(
        asserts=test_asserts,
        state=test_state,
        test_name="foo",
        hostnames=["alpha", "bravo"],
        seconds_between_asserts=0,
    )

    # NOTE: B does not run because I'm pretty sure Dask is pickling
    # the run_assert mock so it will only run the first side effect.
    # At least it runs twice...
    assert results == {"A": [True, True]}
Beispiel #3
0
def test_run_asserts_series_multiple_hosts_one_assert(run_asserts_mock: Mock):
    run_asserts_mock.side_effect = [{
        "A":
        [AssertResult(passed=True, actual="", expected="", description="")]
    }]

    test_state = defaultdict(dict)
    test_asserts = [{"name": "A", "type": "SQLAssert"}]

    results = testing.run_asserts_series(
        asserts=test_asserts,
        state=test_state,
        test_name="foo",
        hostnames=["alpha", "bravo"],
        seconds_between_asserts=0,
    )

    assert results == {
        "A":
        [AssertResult(passed=True, actual="", expected="", description="")]
    }