def test_fetch_transaction_status_transactions_filtering(self): payment_method = PaymentMethodFactory.create( payment_processor=triggered_processor) transactions = TransactionFactory.create_batch( 5, payment_method=payment_method, state=Transaction.States.Pending) filtered_transactions = [ transactions[0], transactions[2], transactions[4] ] mock_fetch_status = MagicMock() with patch.multiple(TriggeredProcessor, fetch_transaction_status=mock_fetch_status): transactions_arg = [ str(transaction.pk) for transaction in filtered_transactions ] call_command('fetch_transactions_status', '--transactions=%s' % ','.join(transactions_arg)) for transaction in filtered_transactions: self.assertIn(call(transaction), mock_fetch_status.call_args_list) self.assertEqual(mock_fetch_status.call_count, len(filtered_transactions))
def test_transaction_filtering(self): payment_method = PaymentMethodFactory.create( payment_processor=triggered_processor, verified=True) transactions = TransactionFactory.create_batch( 5, payment_method=payment_method) filtered_transactions = [ transactions[0], transactions[2], transactions[4] ] mock_execute = MagicMock() with patch.multiple(TriggeredProcessor, execute_transaction=mock_execute): transactions_arg = [ str(transaction.pk) for transaction in filtered_transactions ] call_command('execute_transactions', '--transactions=%s' % ','.join(transactions_arg)) for transaction in filtered_transactions: self.assertIn(call(transaction), mock_execute.call_args_list) self.assertEqual(mock_execute.call_count, len(filtered_transactions))
def test_transaction_executing(self): payment_method = PaymentMethodFactory.create( payment_processor=triggered_processor, verified=True) transactions = TransactionFactory.create_batch( 5, payment_method=payment_method) mock_execute = MagicMock() with patch.multiple(TriggeredProcessor, execute_transaction=mock_execute): call_command('execute_transactions') for transaction in transactions: self.assertIn(call(transaction), mock_execute.call_args_list) self.assertEqual(mock_execute.call_count, len(transactions))
def test_fetch_transaction_status_call(self): payment_method = PaymentMethodFactory.create( payment_processor=triggered_processor) transactions = TransactionFactory.create_batch( 5, payment_method=payment_method, state=Transaction.States.Pending) mock_fetch_status = MagicMock() with patch.multiple(TriggeredProcessor, fetch_transaction_status=mock_fetch_status): call_command('fetch_transactions_status') for transaction in transactions: self.assertIn(call(transaction), mock_fetch_status.call_args_list) self.assertEqual(mock_fetch_status.call_count, len(transactions))