Skip to content

Commit

Permalink
test: with named args
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Feb 26, 2025
1 parent 1249ae8 commit e62e8e7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ exports[`Jinja (new api) render arguments-test.yml.jinja: arguments-test.yml.jin
arg_sum_map: 20
arg_kwargs1: \\"arg1: first value, arg2: second value, kwarg:(3 arg)\\"
arg_kwargs2: \\"arg1: first value, arg2: second value, kwarg:(3 arg,4 arg)\\"
arg_kwargs3: \\"arg1: first value, arg2: second value, kwarg:(3 arg,4 arg,4 arg)\\""
arg_kwargs3: \\"arg1: first value, arg2: second value, kwarg:(4 arg,4 arg,3 arg)\\"
arg_named_arguments1: \\"arg1: 1 arg, arg2: 2 arg\\"
arg_named_arguments2: \\"arg1: 1 arg, arg2: 2 arg\\""
`;

exports[`Jinja (new api) render data-model.yml.jinja: data-model.yml.jinja 1`] = `
Expand Down Expand Up @@ -252,7 +254,7 @@ dump:
exports[`Jinja (new api) render template_error_python.jinja: template_error_python.jinja 1`] = `
[Error: could not render block: Call error: Python error: Exception: Random Exception
Traceback (most recent call last):
File "jinja-instance.py", line 116, in throw_exception
File "jinja-instance.py", line 120, in throw_exception
------------------------- template_error_python.jinja -------------------------
3 | 3
Expand Down
2 changes: 2 additions & 0 deletions packages/cubejs-backend-native/test/jinja.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ suite('Python model', () => {
load_data_sync: expect.any(Object),
arg_bool: expect.any(Object),
arg_kwargs: expect.any(Object),
arg_named_arguments: expect.any(Object),
arg_sum_integers: expect.any(Object),
arg_str: expect.any(Object),
arg_null: expect.any(Object),
Expand Down Expand Up @@ -127,6 +128,7 @@ darwinSuite('Scope Python model', () => {
load_data_sync: expect.any(Object),
arg_bool: expect.any(Object),
arg_kwargs: expect.any(Object),
arg_named_arguments: expect.any(Object),
arg_sum_integers: expect.any(Object),
arg_str: expect.any(Object),
arg_null: expect.any(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ test:
arg_kwargs1: {{ arg_kwargs("first value", "second value", three="3 arg") }}
arg_kwargs2: {{ arg_kwargs("first value", "second value", three="3 arg", four="4 arg") }}
arg_kwargs3: {{ arg_kwargs("first value", "second value", three="3 arg", four="4 arg", five="4 arg") }}
arg_named_arguments1: {{ arg_named_arguments(arg2="2 arg", arg1="1 arg") }}
arg_named_arguments2: {{ arg_named_arguments(arg1="1 arg", arg2="2 arg") }}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def arg_kwargs(arg1, arg2, **kwargs):

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

@template.function
def arg_named_arguments(arg1, arg2):
return "arg1: " + arg1 + ", arg2: " + arg2

@template.function
def arg_seq(a):
return a
Expand Down
9 changes: 5 additions & 4 deletions packages/cubejs-backend-native/test/templates/scoped-utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ def arg_sum_map(obj):
@context_func
def arg_kwargs(**kwargs):
result = ""
kwargs_str = ",".join(kwargs.values())
for arg in kwargs.values():
result += arg
return "arg1: " + arg1 + ", arg2: " + arg2 + ", kwarg:(" + kwargs_str + ")"
return result
@context_func
def arg_named_arguments(arg1, arg2):
return "arg1: " + arg1 + ", arg2: " + arg2
@context_func
def arg_seq(a):
Expand Down

0 comments on commit e62e8e7

Please sign in to comment.