def test_process_transactions_valid_two(self): def my_init(self, xls_path): self.xls = pandas.read_excel(xls_path) with patch.object(RaiffeisenStatement, "__init__", my_init): statement = RaiffeisenStatement( self.get_statement_path(self.def_statement)) transactions = statement._process_transactions() expected_registration_date = datetime(2018, 1, 22, 0, 0) expected_finalization_date = datetime(2018, 1, 22, 0, 0) expected_raw_description = 'OPH/unknown stuff |stuff |stuff' trans = transactions[3] self.assertEqual(trans.registration_date, expected_registration_date) self.assertEqual(trans.finalization_date, expected_finalization_date) self.assertEqual(trans.expense_amount, None) self.assertEqual(trans.income_amount, 100.0) self.assertEqual(trans.raw_description, expected_raw_description) self.assertEqual(trans.payment_order_id, 123) self.assertEqual(trans.beneficiary_financial_code, '12345678') self.assertEqual(trans.final_adjudicator, None) self.assertEqual(trans.final_beneficiary, None) self.assertEqual(trans.involved_party.name, "FIRMA SRL") self.assertEqual(trans.involved_party.bank_name, "SOMEBANK ROMANIA") self.assertEqual(trans.involved_party.account_number, "RO77CITI1234567123456789") self.assertEqual(trans.card_usage_date, None) self.assertEqual(trans.description, expected_raw_description) self.assertEqual(trans.extra_data, None)
def test_process_transactions_valid_one(self): def my_init(self, xls_path): self.xls = pandas.read_excel(xls_path) with patch.object(RaiffeisenStatement, "__init__", my_init): statement = RaiffeisenStatement( self.get_statement_path(self.def_statement)) transactions = statement._process_transactions() expected_registration_date = datetime(2018, 1, 22, 0, 0) expected_finalization_date = datetime(2018, 1, 22, 0, 0) expected_raw_desciption = 'Payment 1 |Card nr. XXXX XXXX XXXX 1234 |Data utilizarii cardului 18/01/2018' trans = transactions[0] self.assertEqual(trans.registration_date, expected_registration_date) self.assertEqual(trans.finalization_date, expected_finalization_date) self.assertEqual(trans.expense_amount, 100.0) self.assertEqual(trans.income_amount, None) self.assertEqual(trans.raw_description, expected_raw_desciption) self.assertEqual(trans.payment_order_id, None) self.assertEqual(trans.beneficiary_financial_code, None) self.assertEqual(trans.final_adjudicator, None) self.assertEqual(trans.final_beneficiary, None) self.assertEqual(trans.involved_party.is_payment(), True) self.assertEqual(trans.card_usage_date, datetime(2018, 1, 18, 0, 0)) self.assertEqual(trans.description, 'Payment 1 ') self.assertEqual(trans.extra_data, 'Card nr. XXXX XXXX XXXX 1234 ')
def test_process_transactions_len(self): def my_init(self, xls_path): self.xls = pandas.read_excel(xls_path) with patch.object(RaiffeisenStatement, "__init__", my_init): statement = RaiffeisenStatement( self.get_statement_path(self.def_statement)) transactions = statement._process_transactions() self.assertEqual(len(transactions), 5)
def test_get_transaction_date_range_valid(self): def my_init(self, xls_path): self.xls = pandas.read_excel(xls_path) with patch.object(RaiffeisenStatement, "__init__", my_init): statement = RaiffeisenStatement( self.get_statement_path(self.def_statement)) expected_from = datetime(2018, 1, 22, 0, 0) expected_to = datetime(2018, 1, 31, 0, 0) self.assertListEqual(statement._get_transaction_date_range(), [expected_from, expected_to])
def test_parse_transaction_date_range(self): input_value = "de la 22/01/2018 la 31/01/2018" expected_from = datetime(2018, 1, 22, 0, 0) expected_to = datetime(2018, 1, 31, 0, 0) self.assertListEqual( RaiffeisenStatement._parse_transaction_date_range(input_value), [expected_from, expected_to])
def test_invalid_file_name_parser_valid_new(self): file_name = "Extras_de_cont_12345678.xlsx" output = RaiffeisenStatement._parse_statement_file_name(file_name) expected = { "account_number": None, "start_generation_time": None, "end_generation_time": None } self.assertDictEqual(output, expected)
def test_file_name_parser_valid(self): file_name = "Extras_de_cont_12345678_01092018_30092018.xls" output = RaiffeisenStatement._parse_statement_file_name(file_name) expected = { "account_number": "12345678", "start_generation_time": self.to_date("01092018", RaiffeisenStatement.FILE_NAME_DATE_FORMAT), "end_generation_time": self.to_date("30092018", RaiffeisenStatement.FILE_NAME_DATE_FORMAT) } self.assertDictEqual(output, expected)
def test_init(self): RaiffeisenStatement(self.get_statement_path(self.def_statement))
def get_statement(self, xls_file_name): return RaiffeisenStatement(self.get_statement_path(xls_file_name))
#!/usr/bin/env python3 from bankreader.romania import RaiffeisenStatement import os statement_xls_path = os.path.join( 'test', 'statements', 'Extras_de_cont_12345678_20012018_31012018.xls') statement = RaiffeisenStatement(xls_path=statement_xls_path) print(statement.account_number) print(statement.client.iban) print(statement.client.client_address) for transaction in statement.transactions: print(transaction.amount) print(transaction.description) print(transaction.is_income)