Ejemplo n.º 1
0
    def test_process_match(self):
        self.skipTest("wip")
        narration = "Amazon.com*MA4TS16T0"
        tx = Transaction(narration=narration,
                         date=None,
                         flag=None,
                         payee=None,
                         tags={},
                         links={},
                         postings=[
                             Posting(account="Liablities:Card",
                                     units=Amount(D(100), "USD"),
                                     cost=None,
                                     price=None,
                                     flag="*",
                                     meta={}),
                             Posting(account="Expenses:FIXME",
                                     units=Amount(D(-100), "USD"),
                                     cost=None,
                                     price=None,
                                     flag="!",
                                     meta={})
                         ],
                         meta={
                             'file_name': '',
                             'lineno': 0
                         })
        m = Matcher([AMAZON_RULE])

        results = m.process([tx])
        self.assertEqual(len(results), 1)
        result = results[0]
        print(yaml.dump(AMAZON_RULE))
Ejemplo n.º 2
0
 def x_rule_filter_set(self):
     expected = {
         'transaction': AMAZON_RULE['set-transaction'],
         'posting': AMAZON_RULE['set-posting'],
     }
     m = Matcher()
     for field, expressions in m.rule_filter('set', AMAZON_RULE):
         self.assertEqual(expected[field], expressions)
Ejemplo n.º 3
0
 def test_rule_filter(self):
     self.skipTest("Invalid Method")
     expected = {
         'narration': AMAZON_RULE['match-narration'],
         'account': AMAZON_RULE['match-account'],
         'tags': ['household'],
     }
     m = Matcher()
     self.assertEqual(m.expand_match_fields(AMAZON_RULE), expected)
Ejemplo n.º 4
0
 def test_match_rule(self):
     self.skipTest("wip")
     narration = "Amazon.com*MA4TS16T0"
     tx = Transaction(narration=narration,
                      date=None,
                      flag=None,
                      payee=None,
                      tags={},
                      links={},
                      postings=[],
                      meta={
                          'file_name': '',
                          'lineno': 0
                      })
     result = Matcher().match_rule(tx, AMAZON_RULE)
     expected = {
         'narration': {
             'match-parameter': 'narration',
             'match-value': narration,
             'match-group': {
                 'payee': 'Amazon.com',
                 'order_id': 'MA4TS16T0'
             }
         }
     }
     self.assertEqual(result, expected)
Ejemplo n.º 5
0
    def test_match(self):
        self.skipTest("wip")

        narration = "Amazon.com*MA4TS16T0"
        tx = Transaction(narration=narration,
                         date=None,
                         flag=None,
                         payee=None,
                         tags={},
                         links={},
                         postings=[],
                         meta={
                             'file_name': '',
                             'lineno': 0
                         })
        m = Matcher([AMAZON_RULE])

        result = m.match(tx)
        self.assertIsInstance(result, dict)

        self.assertEqual(result['rule'], AMAZON_RULE)
        self.assertEqual(result['entry'], tx)
Ejemplo n.º 6
0
 def test_invalidate(self):
     rules = [{'match-date': r"(?P<order)"}]
     m = Matcher()
     self.assertRaises(Exception, m.add_rules, rules)
Ejemplo n.º 7
0
 def test_validate(self):
     rules = [AMAZON_RULE]
     m = Matcher()
     m.add_rules(rules)