You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/06/23 00:04:50 UTC

[airflow] 03/04: Fix failing tests from #9250 (#9307)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 22c95f075c132041b1c8378490399904a32d2682
Author: Kamil BreguĊ‚a <mi...@users.noreply.github.com>
AuthorDate: Mon Jun 15 16:23:11 2020 +0200

    Fix failing tests from #9250 (#9307)
    
    (cherry-picked from 2c18a3f)
---
 airflow/www_rbac/views.py    |  2 --
 tests/www_rbac/test_views.py | 11 ++++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 55a10e9..6ae6ef6 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -1526,8 +1526,6 @@ class Airflow(AirflowBaseView):
 
         # avoid spaces to reduce payload size
         data = htmlsafe_json_dumps(data, separators=(',', ':'))
-        # escape slashes to avoid JSON parse error in JS
-        data = data.replace('\\', '\\\\')
 
         return self.render_template(
             'airflow/tree.html',
diff --git a/tests/www_rbac/test_views.py b/tests/www_rbac/test_views.py
index c668227..116d3d6 100644
--- a/tests/www_rbac/test_views.py
+++ b/tests/www_rbac/test_views.py
@@ -581,11 +581,12 @@ class TestAirflowBaseViews(TestBase):
         self.check_content_in_response('example_bash_operator', resp)
 
     @parameterized.expand([
-        ("hello\nworld", "hello\\\\nworld"),
-        ("hello'world", "hello\\\\u0027world"),
-        ("<script>", "\\\\u003cscript\\\\u003e"),
+        ("hello\nworld", r'\"conf\":{\"abc\":\"hello\\nworld\"}}'),
+        ("hello'world", r'\"conf\":{\"abc\":\"hello\\u0027world\"}}'),
+        ("<script>", r'\"conf\":{\"abc\":\"\\u003cscript\\u003e\"}}'),
+        ("\"", r'\"conf\":{\"abc\":\"\\\"\"}}'),
     ])
-    def test_escape_in_tree_view(self, test_str, seralized_test_str):
+    def test_escape_in_tree_view(self, test_str, expected_text):
         dag = self.dagbag.dags['test_tree_view']
         dag.create_dagrun(
             run_id=self.run_id,
@@ -597,7 +598,7 @@ class TestAirflowBaseViews(TestBase):
 
         url = 'tree?dag_id=test_tree_view'
         resp = self.client.get(url, follow_redirects=True)
-        self.check_content_in_response('"conf":{{"abc":"{}"}}'.format(seralized_test_str), resp)
+        self.check_content_in_response(expected_text, resp)
 
     def test_dag_details_trigger_origin_tree_view(self):
         dag = self.dagbag.dags['test_tree_view']