Skip to content

Commit

Permalink
Fix failing tests from #9250 (#9307)
Browse files Browse the repository at this point in the history
  • Loading branch information
mik-laj authored Jun 15, 2020
1 parent d0e06ef commit 2c18a3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,8 +1508,6 @@ def recurse_nodes(task, visited):

# 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',
Expand Down
11 changes: 6 additions & 5 deletions tests/www/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,12 @@ def test_view_uses_existing_dagbag(self, endpoint, mock_get_dag):
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(
execution_date=self.EXAMPLE_DAG_DEFAULT_DATE,
Expand All @@ -643,7 +644,7 @@ def test_escape_in_tree_view(self, test_str, seralized_test_str):

url = 'tree?dag_id=test_tree_view'
resp = self.client.get(url, follow_redirects=True)
self.check_content_in_response(f'"conf":{{"abc":"{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']
Expand Down

0 comments on commit 2c18a3f

Please sign in to comment.