Пример #1
0
 def read_csv(self, f):
     self.messenger.send_message("Parsing csv-file from" +
                                 self.csv_filename + "...",
                                 preblanks=1)
     transaction_factory = TransactionFactory(self.account_config)
     self.transactions = transaction_factory.read_from_file(
         f, self.messenger)
Пример #2
0
 def test_read_from_file(self):
     fake_csv_file = self.write_fake_csv()
     transaction_factory = TransactionFactory(self.account_config)
     transactions = transaction_factory.read_from_file(
         fake_csv_file, Messenger(False))
     fake_csv_file.close()
     self.assertEqual(len(transactions), 3)
Пример #3
0
 def test_create_transaction_factory(self):
     line = csvline_to_line(csv_line, self.account_config)
     transaction_factory = TransactionFactory(self.account_config)
     transaction = transaction_factory.create_from_line(line)
     self.assertEqual(transaction.date, self.account_config.get_date(line))
     self.assertEqual(transaction.description, self.account_config.get_description(line))
     self.assertEqual(transaction.debit, self.account_config.get_debit(line))
     self.assertEqual(transaction.credit, self.account_config.get_credit(line))
     self.assertEqual(transaction.target_account, self.account_config.default_target_account)
Пример #4
0
    def test_extract_correct_fields(self):
        transaction = (TransactionFactory(self.d)).create_from_line(
            self.get_fixture_line())

        self.assertIsNotNone(transaction.date)
        self.assertEqual('2015-05-22T00:00:00', transaction.date.isoformat())

        self.assertGreater(transaction.debit, 0)
        self.assertGreater(transaction.debit, 8.2)
        self.assertLess(transaction.debit, 9)
        self.assertEqual(transaction.credit, 0)

        self.assertTrue('AMAZON' in transaction.description)
        self.assertTrue('32132131321' in transaction.description)
        self.assertTrue('-8,21' not in transaction.description)
Пример #5
0
 def test_read_from_file(self):
     fake_csv_file = self.write_fake_csv()
     transaction_factory = TransactionFactory(self.account_config)
     transactions = transaction_factory.read_from_file(fake_csv_file, Messenger(False))
     fake_csv_file.close()
     self.assertEqual(len(transactions),3)
Пример #6
0
 def read_csv(self, f):
     self.messenger.send_message("\nParsing csv-file from" + self.csv_filename + "...")
     transaction_factory = TransactionFactory(self.account_config)
     self.transactions = transaction_factory.read_from_file(f, self.messenger)