<commit_before>import unittest
from payeezy import transactions


payeezy = transactions.Transaction
payeezy.TOKEN = '<KEY>'
payeezy.API_SECRET = '<KEY>'
payeezy.API_KEY = 'y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a'


class OverallTestCase(unittest.TestCase):
    def test_purchase(self):
        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '4005519200000004', '1019', '123', '<NAME>')
        self.assertTrue(transaction.is_transaction_approved())

    def test_authorization(self):
        transaction = payeezy()
        transaction.process_authorization('2499', 'visa', '4005519200000004', '1019', '123', 'Donald Duck')
        self.assertTrue(transaction.is_transaction_approved())

if __name__ == '__main__':
    unittest.main()
<commit_msg>Added tests  with missing data for process_purchase().<commit_after>import unittest
from payeezy import transactions


payeezy = transactions.Transaction
payeezy.TOKEN = '<KEY>'
payeezy.API_SECRET = '<KEY>'
payeezy.API_KEY = '<KEY>'


class OverallTestCase(unittest.TestCase):

    def test_authorization(self):
        transaction = payeezy()
        transaction.process_authorization('2499', 'visa', '4005519200000004', '1019', '123', '<NAME>')
        self.assertTrue(transaction.is_transaction_approved())


class ProcessPaymentTestCase(unittest.TestCase):

    def test_payment_with_clean_data(self):
        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '4005519200000004', '1019', '123', '<NAME>')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertTrue(transaction_is_approved)

    def test_payment_without_transaction_total(self):

        transaction = payeezy()
        transaction.process_purchase('', 'visa', '4005519200000004', '1019', '123', '<NAME>')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message may ALSO be:
        # 'The amount provided is invalid'
        expected_error_messages = ['The amount is missing']
        self.assertEqual(transaction_error_messages, expected_error_messages)

    def test_payment_without_card_type(self):

        transaction = payeezy()
        transaction.process_purchase('2499', '', '4005519200000004', '1019', '123', '<NAME>')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message may ALSO be:
        # 'The card type cannot be empty'
        expected_error_messages = ['The card type is invalid']
        self.assertEqual(transaction_error_messages, expected_error_messages)

    def test_payment_without_card_number(self):

        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '', '1019', '123', '<NAME>')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message may ALSO be:
        # 'The card number cannot be empty',
        # 'The card number must be numeric',
        # 'The credit card number check failed'
        # 'American Express card number must be 15 digits'
        expected_error_messages = ['The card number must be 16 digits']
        self.assertEqual(transaction_error_messages, expected_error_messages)

    def test_payment_without_card_expiry(self):

        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '4005519200000004', '', '123', '<NAME>')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message SUPPOSED to be:
        # 'The card has expired'
        expected_error_messages = ['Expiry Date is invalid']
        self.assertEqual(transaction_error_messages, expected_error_messages)

    @unittest.expectedFailure
    # payeezy sandbox API does **not** check cvv and transaction is being approved
    def test_payment_without_card_cvv(self):

        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '4005519200000004', '1019', '', 'Donald Duck')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message SUPPOSED to be:
        # 'The cvv provided must be numeric'
        expected_error_messages = ['RELEVANT_CARD_CVV_ERROR_HERE']
        self.assertEqual(transaction_error_messages, expected_error_messages)

    @unittest.expectedFailure
    # Fails with 400 instead of the relevant API error
    def test_payment_without_cardholder_name(self):

        transaction = payeezy()
        transaction.process_purchase('2499', 'visa', '4005519200000004', '1019', '123', '')

        transaction_is_approved = transaction.is_transaction_approved()
        self.assertFalse(transaction_is_approved)

        transaction_error_messages = transaction.report_transaction_error_messages()
        # according to payeezy sample, expected error message SUPPOSED to be:
        # 'The card holder name cannot be empty'
        expected_error_messages = ['RELEVANT_CARDHOLDER_NAME_ERROR_HERE']
        self.assertEqual(transaction_error_messages, expected_error_messages)


if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.09313725490196079, 'fraction_numerical': 0.04293441514536849, 'mean_word_length': 4.1722027972027975, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 9, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2827107', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1615, 'n_words': 361}