예제 #1
0
def test_mock_usage_fail_validation():
    pact = (Consumer("C").has_pact_with(
        Provider("P"),
        version="3.0.0").given("g").upon_receiving("r").with_request(
            "post", "/foo", body=Like({
                "a": "spam",
                "b": Equals("bee")
            })).will_respond_with(200))

    with pytest.raises(AssertionError), pact:
        requests.post(pact.uri + "/foo", json={"a": "ham", "b": "wasp"})
예제 #2
0
def test_valid_types(object):
    Equals(object)
예제 #3
0
def test_mock_usage_pass_validation():
    pact = Consumer('C').has_pact_with(Provider('P'), version='3.0.0') \
        .given("g").upon_receiving("r").with_request("post", "/foo", body=Like({"a": "spam", "b": Equals("bee")})) \
        .will_respond_with(200)

    with pact:
        requests.post(pact.uri + '/foo', json={"a": "ham", "b": "bee"})
예제 #4
0
def test_v2_not_allowed():
    with pytest.raises(Equals.NotAllowed):
        Consumer('C').has_pact_with(Provider('P'), version='2.0.0') \
            .given("g").upon_receiving("r").with_request("post", "/foo", body=Equals("bee")) \
            .will_respond_with(200)
예제 #5
0
def test_basic_type():
    assert Equals(123).generate_matching_rule_v3() == {
        'matchers': [{
            'match': 'equality'
        }]
    }
예제 #6
0
def test_invalid_types(object):
    with pytest.raises(AssertionError) as e:
        Equals(object)

    assert 'matcher must be one of ' in str(e.value)
예제 #7
0
def test_basic_type():
    assert Equals(123).generate_matching_rule_v3() == {
        "matchers": [{
            "match": "equality"
        }]
    }