Exemplo n.º 1
0
def test():
    data = load_acceptance_test(__file__)

    actual = PactRequest(headers=[])
    expected = PactRequest(headers=[])

    test_result = match(actual, expected)
    assert type(test_result) is Right
Exemplo n.º 2
0
def test():
    data = load_acceptance_test(__file__)

    actual = PactRequest(**data['actual'])
    expected = PactRequest(**data['expected'])

    test_result = match(actual, expected)
    assert type(test_result) is Left
Exemplo n.º 3
0
def test_order_of_headers():
    data = load_acceptance_test(__file__)

    response = PactResponse(headers=[('Accept', 'hippos, alligators')])
    interaction = {'response': {'headers': data['expected']['headers']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 4
0
def test_matching_plain_text():
    data = load_acceptance_test(__file__)

    response = PactResponse(body='alligator named mary')
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
def test_unexpected_number():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={'alligator': {'feet': 4}})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 6
0
def test_empty_headers():
    data = load_acceptance_test(__file__)

    response = PactResponse(headers=[])
    interaction = {'response': {'headers': data['expected']['headers']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
def test_not_null():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={'alligator': {'name': None}})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
def test_different_value_at_key():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={'alligator': {'name': 'Fred'}})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 9
0
def test():
    data = load_acceptance_test(__file__)

    actual = PactRequest(headers=[{'ACCEPT': 'alligators'}])
    expected = PactRequest(headers=[{'Accept': 'alligators'}])

    test_result = match(actual, expected)
    assert type(test_result) is Right
Exemplo n.º 10
0
def test_different_case():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={'alligator': {'favouritecolour': 'red'}})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
def test_different_value_case():
    data = load_acceptance_test(__file__)

    response = PactResponse(headers=[('Accept', 'Alligators')])
    interaction = {'response': {'headers': data['expected']['headers']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 12
0
def test_missing_index():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={'alligator': {'favouriteColours': ['red']}})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 13
0
def test_whitespaces_after_comma():
    data = load_acceptance_test(__file__)

    response = PactResponse(headers=[('Accept', 'alligators, hippos')])
    interaction = {'response': {'headers': data['expected']['headers']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
Exemplo n.º 14
0
def test_headers_match():
    data = load_acceptance_test(__file__)

    response = PactResponse(headers=[('Accept',
                                      'alligators'), ('Content-Type',
                                                      'hippos')])
    interaction = {'response': {'headers': data['expected']['headers']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
Exemplo n.º 15
0
def test():
    data = load_acceptance_test(__file__)

    actual = PactRequest(**data['actual'])
    expected = PactRequest(**data['expected'])

    actual.headers = [{'Content-Type': 'text/plain'}]
    expected.headers = [{'Content-Type': 'text/plain'}]

    test_result = match(actual, expected)
    assert type(test_result) is Right
Exemplo n.º 16
0
def test_different_values():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={
        'favouriteColours': ['red', 'blue'],
        'favouriteNumber': 7
    })
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
Exemplo n.º 17
0
def test_array_in_different_order():
    data = load_acceptance_test(__file__)

    response = PactResponse(
        body={'alligator': {
            'favouriteColours': ['blue', 'red']
        }})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
Exemplo n.º 18
0
def test_different_values():
    data = load_acceptance_test(__file__)

    response = PactResponse(
        body={'alligator': {
            'favouriteNumbers': ['1', 2, '3']
        }})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Left
def test_different_case():
    data = load_acceptance_test(__file__)

    response = PactResponse(
        body={'alligator': {
            'name': 'Mary',
            'phoneNumber': None
        }})
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
Exemplo n.º 20
0
def test_different_status():
    data = load_acceptance_test(__file__)

    response = PactResponse(status=400)
    interaction = {'response': {'status': data['expected']['status']}}
    test_result = match(interaction, response).value

    assert test_result == {
        'status': FAILED,
        'message': data['comment'],
        'expected': data['expected']['status'],
        'actual': 400
    }
Exemplo n.º 21
0
def test_matches():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={
        'alligator': {
            'feet': 4,
            'name': 'Mary',
            'favouriteColours': [
                'red',
                'blue'
            ]
        }
    })
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right
Exemplo n.º 22
0
def test_nested_objects():
    data = load_acceptance_test(__file__)

    response = PactResponse(body={
        'object1': {
            'object2': {
                'object4': {
                    'object5': {
                        'name': 'Mary',
                        'friends': ['Fred', 'John'],
                        'gender': 'F'
                    },
                    'object6': {
                        'phoneNumber': 1234567890
                    }
                }
            },
            'color': 'red'
        }
    })
    interaction = {'response': {'body': data['expected']['body']}}
    test_result = match(interaction, response)

    assert type(test_result) is Right