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_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)))
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'
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_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)) )
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'
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)
def test_validate_gateway_response(gateway_response): validate_gateway_response(gateway_response)