Exemplo n.º 1
0
 def testAccountTagFilter(self):
     filter = Account.tag_filter("foo", "bar")
     self.assertTrue(filter(self.tr, self.bank))
     self.assertFalse(filter(self.tr, self.books))
Exemplo n.º 2
0
 def testHasAccountFilter(self):
     filter = Filter.has_account(self.parser.parse_account("Assets:Bank"))
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr1, self.tr1.entries[1]))
Exemplo n.º 3
0
 def testMatchesFilter(self):
     filter = Filter.matches(re.compile(r"ank"))
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr1, self.tr1.entries[1]))
Exemplo n.º 4
0
 def testFilterAnd(self):
     filter = self.three_entries & self.in_euro
     self.assertFalse(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr2, self.tr2.entries[0]))
Exemplo n.º 5
0
 def testFilterOr(self):
     filter = self.three_entries | self.in_euro
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertTrue(filter(self.tr2, self.tr2.entries[0]))
Exemplo n.º 6
0
 def testExpressionFilterTag(self):
     filter = ExpressionFilter.parse(self.parser, "entry.foo")
     self.assertFalse(filter(self.tr1, self.tr1.entries[0]))
     self.assertTrue(filter(self.tr1, self.tr1.entries[1]))
Exemplo n.º 7
0
 def testFilterParse(self):
     filter = Filter.parse(self.parser, lambda tr, entry: entry.account.name.startswith("Assets"))
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr1, self.tr1.entries[1]))
Exemplo n.º 8
0
 def testExpressionFilter(self):
     filter = ExpressionFilter.parse(self.parser, "entry.account.name.startswith('Assets')")
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr1, self.tr1.entries[1]))
Exemplo n.º 9
0
 def testExpressionFilterDate(self):
     filter = ExpressionFilter.parse(self.parser, "entry.date < date('2010')")
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr2, self.tr2.entries[0]))
     self.assertTrue(filter(self.tr2, self.tr2.entries[1]))
Exemplo n.º 10
0
 def testEntryTagFilter(self):
     filter = Entry.tag_filter("title", "Necronomicon")
     self.assertTrue(filter(self.tr, self.books))
     self.assertFalse(filter(self.tr, self.bank))
     self.assertFalse(filter(self.tr, None))
Exemplo n.º 11
0
 def testEndFilter(self):
     filter = EndFilter.parse(self.parser, "2010")
     self.assertTrue(filter(self.tr1, self.tr1.entries[0]))
     self.assertFalse(filter(self.tr2, self.tr2.entries[0]))
     self.assertTrue(filter(self.tr2, self.tr2.entries[1]))
Exemplo n.º 12
0
 def testTransactionAccountFilter(self):
     filter = Transaction.account_tag_filter("foo", "bar")
     self.assertTrue(filter(self.tr, None))
Exemplo n.º 13
0
 def testTransactionTagFilterWrong(self):
     filter = Transaction.tag_filter("foo", None)
     self.assertFalse(filter(self.tr, self.bank))
     self.assertFalse(filter(self.tr, self.books))
     self.assertFalse(filter(self.tr, None))
Exemplo n.º 14
0
 def testTransactionTagFilterEmpty(self):
     filter = Transaction.tag_filter("baz", None)
     self.assertTrue(filter(self.tr, self.bank))
     self.assertTrue(filter(self.tr, self.books))
     self.assertTrue(filter(self.tr, None))
Exemplo n.º 15
0
 def testTransactionTagFilter(self):
     filter = Transaction.tag_filter("baz", "hello world")
     self.assertTrue(filter(self.tr, self.bank))
     self.assertTrue(filter(self.tr, self.books))
     self.assertTrue(filter(self.tr, None))
Exemplo n.º 16
0
 def testAccountTagFilterWrong(self):
     filter = Account.tag_filter("baz")
     self.assertFalse(filter(self.tr, self.bank))
     self.assertFalse(filter(self.tr, self.books))