You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/04/22 09:26:47 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #8505: [POC] Add more precise tests (tests for jinja params) for AirflowVersion

mik-laj commented on a change in pull request #8505:
URL: https://github.com/apache/airflow/pull/8505#discussion_r412821804



##########
File path: tests/test_utils/asserts.py
##########
@@ -71,3 +72,33 @@ def assert_queries_count(expected_count, message_fmt=None):
                                  "The current number is {current_count}."
     message = message_fmt.format(current_count=result.count, expected_count=expected_count)
     assert expected_count == result.count, message
+
+
+class CatchJinjaParmasResult:
+    def __init__(self):
+        self.template_name = None
+        self.template_params = None
+
+
+@contextmanager
+def catch_jinja_params():
+    """Catch jinja parameters."""
+    result = CatchJinjaParmasResult()
+
+    from flask_appbuilder import BaseView
+
+    with mock.patch(
+        'flask_appbuilder.BaseView.render_template',
+        side_effect=BaseView.render_template,
+        autospec=True
+    ) as mock_render_template:
+        yield result
+
+    assert mock_render_template.call_count == 1, (
+        "It was expected that the BaseView.render_template method would only be called once. "
+        f"This was called {mock_render_template} times."

Review comment:
       ```suggestion
           f"This was called {mock_render_template.call_count} times."
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org