Beispiel #1
0
def test_validate_gateway_response_incorrect_field_type(gateway_response):
    gateway_response['amount'] = 'should-be-decimal'

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == 'amount must be of type {}, was {}'.format(
        Decimal, str)
Beispiel #2
0
def test_validate_gateway_response_incorrect_field_type(gateway_response):
    gateway_response['amount'] = 'should-be-decimal'

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == 'amount must be of type {}, was {}'.format(
        Decimal, str)
def test_validate_gateway_response_incorrect_transaction_kind(
        gateway_response):
    gateway_response.kind = "incorrect-kind"

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == ("Gateway response kind must be one of {}".format(
        sorted(ALLOWED_GATEWAY_KINDS)))
Beispiel #4
0
def test_validate_gateway_response_not_json_serializable(gateway_response):
    class CustomClass(object):
        pass
    gateway_response.raw_response = CustomClass()

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == 'Gateway response needs to be json serializable'
Beispiel #5
0
def test_validate_gateway_response_missing_required_key(gateway_response):
    del gateway_response['is_success']

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == (
        'Gateway response needs to contain following keys: {}'.format(
            sorted(REQUIRED_GATEWAY_KEYS)))
Beispiel #6
0
def test_validate_gateway_response_incorrect_transaction_kind(gateway_response):
    gateway_response.kind = "incorrect-kind"

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == (
        "Gateway response kind must be one of {}".format(sorted(ALLOWED_GATEWAY_KINDS))
    )
Beispiel #7
0
def test_validate_gateway_response_not_json_serializable(gateway_response):
    class CustomClass(object):
        pass
    gateway_response['extra'] = CustomClass()

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == 'Gateway response needs to be json serializable'
Beispiel #8
0
def test_validate_gateway_response_missing_required_key(gateway_response):
    del gateway_response['is_success']

    with pytest.raises(GatewayError) as e:
        validate_gateway_response(gateway_response)

    assert str(e.value) == (
        'Gateway response needs to contain following keys: {}'.format(
            sorted(REQUIRED_GATEWAY_KEYS)))
def test_validate_gateway_response(gateway_response):
    validate_gateway_response(gateway_response)
Beispiel #10
0
def test_validate_gateway_response(gateway_response):
    validate_gateway_response(gateway_response)