def test_premium_payment_gateway_using_function_calling(
         self, make_transaction, app_):
     """
     Test premium payment gateway called with their own class make_transaction function
     """
     with app_.test_request_context(
     ):  # this is for current_app.debug used at make_request for debugging purpose
         transaction_flow = OnlineTransaction(
             '5555555555554444',
             'syed hassan raza',
             datetime.datetime(2021, 12, 12),
             521,  # premium amount
             security_code=321)
         transaction_flow.make_transaction()
         make_transaction.assert_called_once()
 def test_premium_payment_gateway_retries(self, make_request, app_):
     """
     Test premium payment gateway with retries
     """
     with app_.test_request_context(
     ):  # this is for current_app.debug used at make_request for debugging purpose
         transaction_flow = OnlineTransaction(
             '5555555555554444',
             'syed hassan raza',
             datetime.datetime(2021, 12, 12),
             521,  # premium amount
             security_code=321)
         transaction_flow.make_transaction()
         #  second call with transaction call contains retries
         args, kwargs = make_request.call_args_list[1]
         assert kwargs['retries'] == 3
Example #3
0
 def post(self):
     request_arguments = request_parser.parse_args()
     transaction_flow = OnlineTransaction(
         request_arguments.CreditCardNumber,
         request_arguments.CardHolder,
         request_arguments.ExpirationDate,
         request_arguments.Amount,
         security_code=request_arguments.SecurityCode)
     result = transaction_flow.make_transaction()
     self.status_code = result['status_code']
     self.response_data = result['data']
     return self.send_response()
 def test_premium_payment_gateway(self, app_):
     """
     Test premium payment gateway response.
     """
     with app_.test_request_context(
     ):  # this is for current_app.debug used at make_request for debugging purpose
         transaction_flow = OnlineTransaction(
             '5555555555554444',
             'syed hassan raza',
             datetime.datetime(2021, 12, 12),
             521,  # premium amount
             security_code=321)
         result = transaction_flow.make_transaction()
         assert result['status_code'] == 200
         assert result['data'] == 'ok'
 def test_expensive_payment_failure(self, make_transaction, make_request,
                                    app_):
     """
     Test expensive payment gateway failure with cheap payment gateway
     first side effect will throw failure that expensive_payment is unavailable and move to cheap payment gateway
     """
     with app_.test_request_context(
     ):  # this is for current_app.debug used at make_request for debugging purpose
         transaction_flow = OnlineTransaction(
             '5555555555554444',
             'syed hassan raza',
             datetime.datetime(2021, 12, 12),
             450,  # expensive amount
             security_code=321)
         result = transaction_flow.make_transaction()
         make_transaction.assert_called_once()
         assert result['status_code'] == 200
         assert result['data'] == 'ok'