Skip to content

Commit 36d4e13

Browse files
committed
add invoice_template tests
1 parent 44910aa commit 36d4e13

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/test_invoice_template.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
from invoice2data.extract.invoice_template import InvoiceTemplate
3+
4+
5+
def test_template_with_exclude_keyword_is_not_matched():
6+
optimized_str = "Basic Test Which should not pass because of the word Exclude_this"
7+
InvoiceTempl = InvoiceTemplate(
8+
[
9+
("keywords", ["Basic Test"]),
10+
("exclude_keywords", ["Exclude_this"]),
11+
("template_name", "excludekeywordnotlist.yml"),
12+
("priority", 5),
13+
("issuer", "Basic Test"),
14+
]
15+
)
16+
template_matched = InvoiceTemplate.matches_input(InvoiceTempl, optimized_str)
17+
assert (
18+
template_matched is False
19+
), "yeah, A template with exclude keywords is not matched"
20+
21+
22+
def test_skip_template_with_too_long_lang_code():
23+
24+
OPTIONS_TEST = {
25+
"currency": "EUR",
26+
"date_formats": [],
27+
"languages": ["aaa"],
28+
"decimal_separator": ".",
29+
"replace": [],
30+
}
31+
32+
tpl = {}
33+
tpl["keywords"] = ["Basic Test"]
34+
tpl["exclude_keywords"] = []
35+
tpl["options"] = OPTIONS_TEST
36+
tpl["template_name"] = "3_char_langcode.yml"
37+
try:
38+
InvoiceTempl = InvoiceTemplate(tpl)
39+
except Exception:
40+
assert True, "Template with language code != 2 characters is not initiated"
41+
else:
42+
print("InvoiceTempl is\n%s" % InvoiceTempl)
43+
debug = InvoiceTempl["options"]
44+
print("debug is\n%s" % debug)
45+
assert False, "Template class initiated with language code other then 2"

0 commit comments

Comments
 (0)