Skip to content

Commit

Permalink
Add more test cases to capture edge cases for ctx().get()
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dcoder committed Apr 10, 2020
1 parent 6990e5d commit c5ef955
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
class JinjaFacadeVariableExtractionTest(test_base.ExpressionFacadeEvaluatorTest):

def test_empty_extraction(self):
expr = '{{ just_text and $not_a_var and notctx(foo) and notctx("bar") and notctx(\'fu\') }}'
expr = (
'{{ just_text and $not_a_var and '
'notctx(foo) and notctx("bar") and notctx(\'fu\') '
'ctx("foo\') and ctx(\'foo") and ctx(foo") and '
'ctx("foo) and ctx(foo\') and ctx(\'foo) }}'
)

self.assertListEqual([], expr_base.extract_vars(expr))

Expand Down Expand Up @@ -124,7 +129,8 @@ def test_ignore_ctx_dict_funcs(self):
def test_ignore_ctx_get_func_calls(self):
expr = (
'{{ctx().get(foo) and ctx().get(bar) and ctx().get("fu") and ctx().get(\'baz\') and '
'ctx().get(foo, "bar") and ctx().get("fu", "bar") and ctx().get(\'bar\', \'foo\') }}'
'ctx().get(foo, "bar") and ctx().get("fu", "bar") and ctx().get(\'bar\', \'foo\') and '
'ctx().get("foo\') and ctx().get(\'foo") and ctx().get("foo) and ctx().get(foo") }}'
)

expected_vars = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
class YAQLFacadeVariableExtractionTest(test_base.ExpressionFacadeEvaluatorTest):

def test_empty_extraction(self):
expr = '<% just_text and $not_a_var and notctx(foo) and notctx("bar") and notctx(\'fu\') %>'
expr = (
'<% just_text and $not_a_var and '
'notctx(foo) and notctx("bar") and notctx(\'fu\') '
'ctx("foo\') and ctx(\'foo") and ctx(foo") and '
'ctx("foo) and ctx(foo\') and ctx(\'foo) %>'
)

self.assertListEqual([], expr_base.extract_vars(expr))

Expand Down Expand Up @@ -121,7 +126,8 @@ def test_ignore_ctx_dict_funcs(self):
def test_ignore_ctx_get_func_calls(self):
expr = (
'<%ctx().get(foo) and ctx().get(bar) and ctx().get("fu") and ctx().get(\'baz\') and '
'ctx().get(foo, "bar") and ctx().get("fu", "bar") and ctx().get(\'bar\', \'foo\') %>'
'ctx().get(foo, "bar") and ctx().get("fu", "bar") and ctx().get(\'bar\', \'foo\') and '
'ctx().get("foo\') and ctx().get(\'foo") and ctx().get("foo) and ctx().get(foo") %>'
)

expected_vars = []
Expand Down

0 comments on commit c5ef955

Please sign in to comment.