def test_summarize_transactions_with_threshold(self):
        trans = sankey_gen.parse_csv('data/test-data.csv')

        results = sankey_gen.summarize_transactions(transactions=trans,
                                                    use_labels=False,
                                                    threshold=50)

        expected = {
            'Restaurants': 74,
            'Hotel': 105,
            'Bad Category': 52,
            'Misc': 83
        }
        self.assertDictEqual(results, expected)
    def test_filter_by_date(self):
        trans = sankey_gen.parse_csv('data/test-data.csv')

        start_date = datetime.strptime('06/01/2018', '%m/%d/%Y')
        end_date = datetime.strptime('07/01/2018', '%m/%d/%Y')

        results = sankey_gen.filter_transactions(transactions=trans,
                                                 start_date=start_date,
                                                 end_date=end_date,
                                                 vendors=[],
                                                 categories=[],
                                                 ignore=True,
                                                 use_labels=False)

        self.assertEqual(len(results), 3)
    def test_add_transactions(self):
        trans = sankey_gen.parse_csv('data/test-data.csv')

        f = open(self.output_fname, 'w')
        sankey_gen.add_transactions(f, trans, 1000, self.config)
        f.close()

        with open(self.output_fname, 'r') as f:
            results = f.readlines()

        expected = [
            'Take Home [78] Hotel\n', 'Take Home [12] Misc\n',
            'Take Home [910] Savings\n'
        ]
        self.assertListEqual(results, expected)
    def test_summarize_transactions_with_label(self):
        trans = sankey_gen.parse_csv('data/test-data.csv')

        results = sankey_gen.summarize_transactions(transactions=trans,
                                                    use_labels=True,
                                                    threshold=0)

        expected = {
            'Bad Category': 82,
            'Restaurants': 44,
            'Hotel': 105,
            'Gas & Fuel': 24,
            'Groceries': 24,
            'Income': 35
        }
        self.assertDictEqual(results, expected)
 def test_parse_csv(self):
     results = sankey_gen.parse_csv('data/test-data.csv')
     self.assertEqual(len(results), 11)