Skip to content

Commit e62e8e7

Browse files
committed
test: with named args
1 parent 1249ae8 commit e62e8e7

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

packages/cubejs-backend-native/test/__snapshots__/jinja.test.ts.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ exports[`Jinja (new api) render arguments-test.yml.jinja: arguments-test.yml.jin
188188
arg_sum_map: 20
189189
arg_kwargs1: \\"arg1: first value, arg2: second value, kwarg:(3 arg)\\"
190190
arg_kwargs2: \\"arg1: first value, arg2: second value, kwarg:(3 arg,4 arg)\\"
191-
arg_kwargs3: \\"arg1: first value, arg2: second value, kwarg:(3 arg,4 arg,4 arg)\\""
191+
arg_kwargs3: \\"arg1: first value, arg2: second value, kwarg:(4 arg,4 arg,3 arg)\\"
192+
arg_named_arguments1: \\"arg1: 1 arg, arg2: 2 arg\\"
193+
arg_named_arguments2: \\"arg1: 1 arg, arg2: 2 arg\\""
192194
`;
193195

194196
exports[`Jinja (new api) render data-model.yml.jinja: data-model.yml.jinja 1`] = `
@@ -252,7 +254,7 @@ dump:
252254
exports[`Jinja (new api) render template_error_python.jinja: template_error_python.jinja 1`] = `
253255
[Error: could not render block: Call error: Python error: Exception: Random Exception
254256
Traceback (most recent call last):
255-
File "jinja-instance.py", line 116, in throw_exception
257+
File "jinja-instance.py", line 120, in throw_exception
256258
257259
------------------------- template_error_python.jinja -------------------------
258260
3 | 3

packages/cubejs-backend-native/test/jinja.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ suite('Python model', () => {
9292
load_data_sync: expect.any(Object),
9393
arg_bool: expect.any(Object),
9494
arg_kwargs: expect.any(Object),
95+
arg_named_arguments: expect.any(Object),
9596
arg_sum_integers: expect.any(Object),
9697
arg_str: expect.any(Object),
9798
arg_null: expect.any(Object),
@@ -127,6 +128,7 @@ darwinSuite('Scope Python model', () => {
127128
load_data_sync: expect.any(Object),
128129
arg_bool: expect.any(Object),
129130
arg_kwargs: expect.any(Object),
131+
arg_named_arguments: expect.any(Object),
130132
arg_sum_integers: expect.any(Object),
131133
arg_str: expect.any(Object),
132134
arg_null: expect.any(Object),

packages/cubejs-backend-native/test/templates/arguments-test.yml.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ test:
1818
arg_kwargs1: {{ arg_kwargs("first value", "second value", three="3 arg") }}
1919
arg_kwargs2: {{ arg_kwargs("first value", "second value", three="3 arg", four="4 arg") }}
2020
arg_kwargs3: {{ arg_kwargs("first value", "second value", three="3 arg", four="4 arg", five="4 arg") }}
21+
arg_named_arguments1: {{ arg_named_arguments(arg2="2 arg", arg1="1 arg") }}
22+
arg_named_arguments2: {{ arg_named_arguments(arg1="1 arg", arg2="2 arg") }}

packages/cubejs-backend-native/test/templates/jinja-instance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def arg_kwargs(arg1, arg2, **kwargs):
3939

4040
return "arg1: " + arg1 + ", arg2: " + arg2 + ", kwarg:(" + kwargs_str + ")"
4141

42+
@template.function
43+
def arg_named_arguments(arg1, arg2):
44+
return "arg1: " + arg1 + ", arg2: " + arg2
45+
4246
@template.function
4347
def arg_seq(a):
4448
return a

packages/cubejs-backend-native/test/templates/scoped-utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ def arg_sum_map(obj):
2727
2828
@context_func
2929
def arg_kwargs(**kwargs):
30-
result = ""
30+
kwargs_str = ",".join(kwargs.values())
3131
32-
for arg in kwargs.values():
33-
result += arg
32+
return "arg1: " + arg1 + ", arg2: " + arg2 + ", kwarg:(" + kwargs_str + ")"
3433
35-
return result
34+
@context_func
35+
def arg_named_arguments(arg1, arg2):
36+
return "arg1: " + arg1 + ", arg2: " + arg2
3637
3738
@context_func
3839
def arg_seq(a):

0 commit comments

Comments
 (0)