Exemple #1
0
    def test_extract_from_file__ensure_sorted(self):
        entries, _, __ = loader.load_string("""

          2016-02-03 * "C"
            Assets:Account1    10.00 USD
            Assets:Account2   -10.00 USD

          2016-02-01 * "A"
            Assets:Account1    10.00 USD
            Assets:Account2   -10.00 USD

          2016-02-02 * "B"
            Assets:Account1    10.00 USD
            Assets:Account2   -10.00 USD

        """)

        imp = mock.MagicMock()
        imp.identify = mock.MagicMock(return_value=True)
        imp.extract = mock.MagicMock(return_value=entries)
        new_entries, dup_entries = extract.extract_from_file(
            '/tmp/blabla.ofx', imp)
        self.assertEqual(3, len(entries))
        self.assertTrue(
            misc_utils.is_sorted(new_entries, key=lambda entry: entry.date))
        self.assertEqual([], dup_entries)
 def test_is_sorted(self):
     self.assertTrue(misc_utils.is_sorted([1, 3, 4, 5, 5, 6, 8]))
     self.assertFalse(
         misc_utils.is_sorted([1, 3, 4, 5, 5, 6, 8], cmp=operator.lt))
     self.assertFalse(misc_utils.is_sorted([3, 2, 6, 7]))
     self.assertTrue(misc_utils.is_sorted([7, 6, 3, 1], cmp=operator.gt))