예제 #1
0
class TestTransactionFactory(unittest.TestCase):

    def setUp(self):
        self.account_config = DBGiro()

    def write_fake_csv(self):
        fake_file = StringIO()
        csv.register_dialect(
            'test_dialect',
            self.account_config.get_csv_dialect()
        )
        csv_writer = csv.writer(fake_file, 'test_dialect')
        for row in csv_test_file:
            csv_writer.writerow(row)
        fake_file.seek(0, 0)
        return fake_file

    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)

    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)
예제 #2
0
 def test_getters(self):
     account_config = DBGiro()
     line = csvline_to_line(self.csv, account_config)
     date = datetime(2015, 4, 22)
     description = 'SEPA-Überweisung an Smith, John Rent'
     debit = 10
     credit = 0
     self.assertEqual(account_config.get_date(line), date)
     self.assertEqual(account_config.get_description(line), description)
     self.assertEqual(account_config.get_debit(line), debit)
     self.assertEqual(account_config.get_credit(line), credit)
예제 #3
0
 def test_getters(self):
     account_config = DBGiro()
     line = csvline_to_line(self.csv, account_config)
     date = datetime(2015, 4, 22)
     description = 'SEPA-Überweisung an Smith, John Rent'
     debit = 10
     credit = 0
     self.assertEqual(account_config.get_date(line), date)
     self.assertEqual(account_config.get_description(line), description)
     self.assertEqual(account_config.get_debit(line), debit)
     self.assertEqual(account_config.get_credit(line), credit)