Ejemplo n.º 1
0
 def test_build_bank(self):
     b2yb = build_bank(self.defaults)
     self.assertIsInstance(b2yb, B2YBank)
     nullconfig = fix_conf_params(self.cp, "test_plugin")
     nullb = build_bank(nullconfig)
     self.assertIsInstance(nullb, NullBank)
     missingconf = fix_conf_params(self.cp, "test_plugin_missing")
     self.assertRaises(ImportError, build_bank, missingconf)
Ejemplo n.º 2
0
 def test_write_data(self):
     """
     Test that the right amount of files are created
     and that the file paths end up where we expect
     # to do - make sure file contents are what we expect
     """
     # if you need more tests, add sections to test.conf & specify them here
     # todo: incorporate multiple-file scenarios
     # todo: allow incremental file suffixes when files named the same
     for section_name, num_records, fpath in [
         ("test_record_i18n", 74, "fixed_test_raiffeisen_01.csv"),
         ("test_record_headers", 74, "fixed_test_headers.csv")
     ]:
         config = fix_conf_params(self.cp, section_name)
         b = B2YBank(config, self.py2)
         for f in b.get_files():
             output_data = b.read_data(f)
             self.assertEqual(len(output_data), num_records)
             result_file = b.write_data(f, output_data)
             # check the file is where we expect it to be
             expected_file = abspath(join('test-data', fpath))
             self.assertTrue(exists(expected_file))
             self.assertEqual(expected_file, result_file)
             # todo: check actual contents are what we expect
             os.unlink(expected_file)
Ejemplo n.º 3
0
    def test_fix_row(self):
        """ Check output row is the same across different formats """
        # todo: something where the row format is invalid
        # if you need more tests, add sections to test.conf & specify them here
        for section_name in [
                "test_row_format_default", "test_row_format_neg_inflow",
                "test_row_format_CD_flag", "test_row_format_invalid"
        ]:
            config = fix_conf_params(self.cp, section_name)
            b = B2YBank(config, self.py2)
            for f in b.get_files():
                output_data = b.read_data(f)
                # test the same two rows in each scenario
                for row, expected_row in [(23, [
                        "28.09.2017", "HOFER DANKT  0527  K2   28.09. 17:17",
                        "", "HOFER DANKT  0527  K2   28.09. 17:17", "44.96", ""
                ]),
                                          (24, [
                                              "28.09.2017", "SOFTWARE Wien",
                                              "", "SOFTWARE Wien", "", "307.67"
                                          ])]:
                    result_row = output_data[row]

                    if (self.py2):
                        self.assertItemsEqual(expected_row, result_row)
                    else:
                        self.assertCountEqual(expected_row, result_row)
Ejemplo n.º 4
0
 def test_read_data(self):
     # if you need more tests, add sections to test.conf & specify them here
     for section_name, num_records, fpath in [
         ("test_record_i18n", 74, "test_raiffeisen_01.csv"),
         ("test_record_headers", 74, "test_headers.csv")
     ]:
         config = fix_conf_params(self.cp, section_name)
         b = B2YBank(config, self.py2)
         records = b.read_data(join("test-data", fpath))
         self.assertEqual(len(records), num_records)
Ejemplo n.º 5
0
 def test_read_data(self):
     """ Test that the right number of rows are read from the test files """
     # if you need more tests, add sections to test.conf & specify them here
     for section_name, num_records, fpath in [
         ("test_record_i18n", 74, "test_raiffeisen_01.csv"),
         ("test_record_headers", 74, "test_headers.csv"),
         ("test_delimiter_tab", 74, "test_delimiter_tab.csv")
     ]:
         config = fix_conf_params(self.cp, section_name)
         b = B2YBank(config, self.py2)
         records = b.read_data(join("test-data", fpath))
         self.assertEqual(len(records), num_records)
Ejemplo n.º 6
0
 def test_read_data(self):
     """ Test that the right number of rows are read from the test files """
     # if you need more tests, add sections to test.conf & specify them here
     (section_name, num_records,
      fpath) = ("test_jlp_card", 11,
                "MS_JANE_SMITH_01-12-2019_14-12-2019.csv")
     config = fix_conf_params(self.cp, section_name)
     b = JLP_Card_UKPlugin(config, self.py2)
     records = b.read_data(join("test-data", fpath))
     self.assertEqual(len(records), num_records)
     self.assertEqual(records[10][5], "1100.00")
     self.assertEqual(records[4][4], "80.99")
Ejemplo n.º 7
0
    def test_valid_row(self):
        """ Test making sure row has an outflow or an inflow """
        config = fix_conf_params(self.cp, "test_row_format_default")
        b = B2YBank(config, self.py2)

        for row, row_validity in [
            (["28.09.2017", "Payee", "", "", "300", ""], True),
            (["28.09.2017", "Payee", "", "", "", "400"], True),
            (["28.09.2017", "Payee", "", "", "", ""], False),
        ]:
            is_valid = b._valid_row(row)
            self.assertEqual(is_valid, row_validity)
Ejemplo n.º 8
0
    def test_auto_memo(self):
        """ Test auto-filling empty memo field with payee data """
        config = fix_conf_params(self.cp, "test_row_format_default")
        b = B2YBank(config, self.py2)
        memo_index = b.config["output_columns"].index("Memo")

        for row, test_memo, fill_memo in [
            (["28.09.2017", "Payee", "", "", "300", ""], "", False),
            (["28.09.2017", "Payee", "", "Memo", "300", ""], "Memo", False),
            (["28.09.2017", "Payee", "", "", "300", ""], "Payee", True),
            (["28.09.2017", "Payee", "", "Memo", "", "400"], "Memo", True)
        ]:
            new_memo = b._auto_memo(row, fill_memo)[memo_index]
            self.assertEqual(test_memo, new_memo)
Ejemplo n.º 9
0
 def test_read_data(self):
     cp, is_py2 = get_test_confparser()
     sbc = fix_conf_params(cp, "test_plugin_swedebank")
     sb = swedebank.build_bank(sbc, is_py2)
     self.assertIsInstance(sb, swedebank.SwedebankPlugin)
     self.assertEqual("SwedeBank", sb.name)
     data = sb.read_data(join("test-data", "test_swedebank_statement.xls"))
     self.assertEqual(len(data), 13)
     # check date parsing was correct
     self.assertEqual(data[0][0], "01/10/2014")
     # check record correctly set as outflow
     self.assertEqual(data[0][4], "15.31")
     # check record correctly set as inflow
     self.assertEqual(data[-1][5], "2863.63")
Ejemplo n.º 10
0
    def test_get_files(self):
        """ Test it's finding the right amount of files"""
        # if you need more tests, add sections to test.conf & specify them here
        for section_name, num_files in [("test_num_files", 2),
                                        ("test_num_files_noexist", 0),
                                        ("test_num_files_extension", 0),
                                        ("test_regex", 1),
                                        ("test_regex_noexist", 0)]:

            config = fix_conf_params(self.cp, section_name)
            b = B2YBank(config, self.py2)
            files = b.get_files()
            self.assertEqual(len(files), num_files)
            # hack config to make sure we can deal with absolute paths too
            b.config["path"] = abspath("test-data")
            files = b.get_files()
            self.assertEqual(len(files), num_files)
Ejemplo n.º 11
0
    def test_fix_outflow(self):
        """ Test conversion of negative Inflow into Outflow """
        config = fix_conf_params(self.cp, "test_row_format_default")
        b = B2YBank(config, self.py2)

        for row, expected_row in [
            (["28.09.2017", "Payee", "", "", "300",
              ""], ["28.09.2017", "Payee", "", "", "300", ""]),
            (["28.09.2017", "Payee", "", "", "",
              "-300"], ["28.09.2017", "Payee", "", "", "300", ""]),
            (["28.09.2017", "Payee", "", "", "",
              "300"], ["28.09.2017", "Payee", "", "", "", "300"])
        ]:
            result_row = b._fix_outflow(row)
            if (self.py2):
                self.assertItemsEqual(expected_row, result_row)
            else:
                self.assertCountEqual(expected_row, result_row)