Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_transaction_error_property(self):
""" Test ValidationError class 'transaction_error' property"""
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=Account(
account_code='transactionmock'
)
)
# Mock 'save transaction' request to throw declined
# transaction validation error
with self.mock_request('transaction/declined-transaction.xml'):
try:
transaction.save()
except ValidationError as e:
error = e
transaction_error = error.transaction_error
def test_unexpected_errors_thrown(self):
""" Test UnexpectedClientError class """
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=Account(
account_code='transactionmock'
)
)
# Mock 'save transaction' request to throw unexpected client error
with self.mock_request('transaction/error-teapot.xml'):
try:
transaction.save()
except UnexpectedStatusError as e:
error = e
self.assertIsInstance(error, UnexpectedClientError)
def test_transaction_error_code_property(self):
""" Test ValidationError class 'transaction_error_code' property"""
transaction = Transaction(
amount_in_cents=1000,
currency='USD',
account=Account(
account_code='transactionmock'
)
)
# Mock 'save transaction' request to throw declined
# transaction validation error
with self.mock_request('transaction/declined-transaction.xml'):
try:
transaction.save()
except ValidationError as e:
error = e
self.assertEqual(error.transaction_error_code, 'insufficient_funds')