Skip to content

Commit 535ebff

Browse files
author
Fran
committed
add obj tests
1 parent bcdb94e commit 535ebff

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

tests/obj.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"engine": "Python",
3+
"file": "tests/obj.py",
4+
"params": {
5+
"param1": "Python Obj"
6+
},
7+
"template": "tests/obj.ntpl"
8+
}

tests/obj.ntpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
{:;local::param1:}

tests/obj.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Test neutral python objects."""
2+
3+
def main(params=None):
4+
"""Test neutral python objects."""
5+
6+
if params is None:
7+
params = {}
8+
9+
return {
10+
"data": {
11+
"param1": params.get("param1", "_none"),
12+
}
13+
}

tests/test_neutral_template.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
{:^;:}{:replace; /{:;__test-nts:}/{:;__test-arr-nts->0:}/ >> {:;__hello-nts:} :}
4343
{:^;:}{:same; /{:;__test-nts:}/{:;__test-nts:}/ >> {:;__test-nts:} :}
4444
{:^;:}{:trans; {:trans; Hello nts :} :}
45+
{:^;:}{:obj; tests/obj.json :}
4546
{:^cache; /3/ >>
4647
{:^;:}::--::{:^date; %S :}::--::
4748
{:^;:}{:sum; /{:;one:}/{:;one:}/ :}
@@ -72,6 +73,7 @@
7273
{:^;:}{:replace; /{:;__test-nts:}/{:;__test-arr-nts->0:}/ >> {:;__hello-nts:} :}
7374
{:^;:}{:same; /{:;__test-nts:}/{:;__test-nts:}/ >> {:;__test-nts:} :}
7475
{:^;:}{:trans; {:trans; Hello nts :} :}
76+
{:^;:}{:obj; tests/obj.json :}
7577
{:!cache;
7678
{:^;:}::--::{:^date; %S :}::--::
7779
{:^;:}{:sum; /{:;one:}/{:;one:}/ :}
@@ -102,6 +104,7 @@
102104
{:^;:}{:replace; /{:;__test-nts:}/{:;__test-arr-nts->0:}/ >> {:;__hello-nts:} :}
103105
{:^;:}{:same; /{:;__test-nts:}/{:;__test-nts:}/ >> {:;__test-nts:} :}
104106
{:^;:}{:trans; {:trans; Hello nts :} :}
107+
{:^;:}{:obj; tests/obj.json :}
105108
:}
106109
:}
107110
""".strip()
@@ -372,7 +375,7 @@ def test_bif_cache_complete(self):
372375
template.set_source(TEMPLATE_CACHE)
373376
template.merge_schema(SCHEMA2)
374377
contents = template.render()
375-
expected = "2<div id=\"\" class=\"neutral-fetch-auto \" data-url=\"/url\" data-wrap=\"\">\n loading...\n</div>one|two|threeHello ntsHello nts0one1two2threetrueHello ntsHello ntscontainsis definedelsentsis filled01234567895c96e4f24ce6e234e6bd4df066748030en{:neutral; {:;__test-nts:} >> {:;__test-nts:} :}1Hello onentsHello"
378+
expected = "2<div id=\"\" class=\"neutral-fetch-auto \" data-url=\"/url\" data-wrap=\"\">\n loading...\n</div>one|two|threeHello ntsHello nts0one1two2threetrueHello ntsHello ntscontainsis definedelsentsis filled01234567895c96e4f24ce6e234e6bd4df066748030en{:neutral; {:;__test-nts:} >> {:;__test-nts:} :}1Hello onentsHelloPython Obj"
376379

377380
result_write_parts = contents.split("::--::")
378381
self.assertEqual(result_write_parts[0], "<div1>1nts</div1><div2>2nts</div2><div3>3nts</div3>")

0 commit comments

Comments
 (0)