def test_should_only_fill_when_all_matches_match(self): credit_account_key = "credit_account" prefill_config = [{ "match": { "purpose": ".*VACATION.*", "payee": "vacation_company" }, "fill": { credit_account_key: "expenses:vacation" } }] matching_transaction = { "payee": "vacation_company", "purpose": "VACATION on an island", } other_transaction = { "payee": "spouse", "purpose": "VACATION on an island", } matching_result = fill(matching_transaction, prefill_config) other_result = fill(other_transaction, prefill_config) self.assertEquals(matching_result, {"credit_account": "expenses:vacation"}) self.assertEquals(other_result, {})
def test_should_fill_when_regex_matches(self): prefill_config = [ { "match": {"purpose": ".*SUPERMARKET.*"}, "fill": {"credit_account": "expenses:daily:groceries"} } ] transaction = { "date": "2018/03/19", "amount": "535", "currency": "EUR", "payee": "someone", "posting": "some kind of credit", "purpose": "Thank you for your purchase at SUPERMARKET", } result = fill(transaction, prefill_config) self.assertEquals(result, {"credit_account": "expenses:daily:groceries"})