コード例 #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)
コード例 #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)
コード例 #3
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)))
コード例 #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'
コード例 #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)))
コード例 #6
0
ファイル: test_payment.py プロジェクト: mirumee/saleor
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))
    )
コード例 #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'
コード例 #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)))
コード例 #9
0
def test_validate_gateway_response(gateway_response):
    validate_gateway_response(gateway_response)
コード例 #10
0
ファイル: test_payment.py プロジェクト: mirumee/saleor
def test_validate_gateway_response(gateway_response):
    validate_gateway_response(gateway_response)