def test_params_all(self): query = utils.get_params(status='active', page=3, search='bash_') assert { 'page': ['3'], 'search': ['bash_'], 'status': ['active'] } == parse_qs(query)
def test_params_all(self): query = utils.get_params(showPaused=False, page=3, search='bash_') self.assertEqual( { 'page': ['3'], 'search': ['bash_'], 'showPaused': ['False'] }, parse_qs(query))
def test_params_showPaused(self, show_paused, hide_by_default, expected_result): with conf_vars({ ('webserver', 'hide_paused_dags_by_default'): str(hide_by_default) }): self.assertEqual(expected_result, utils.get_params(showPaused=show_paused))
def test_params_all(self): query = utils.get_params(showPaused=False, page=3, search='bash_') self.assertEqual( {'page': ['3'], 'search': ['bash_'], 'showPaused': ['False']}, parse_qs(query) )
def test_params_no_values(self): """Should return an empty string if no params are passed""" self.assertEqual('', utils.get_params())
def test_params_none_and_zero(self): qs = utils.get_params(a=0, b=None) # The order won't be consistent, but that doesn't affect behaviour of a browser pairs = list(sorted(qs.split('&'))) self.assertListEqual(['a=0', 'b='], pairs)
def test_params_showPaused_false(self): self.assertEqual('showPaused=False', utils.get_params(showPaused=False))
def test_params_search(self): assert 'search=bash_' == utils.get_params(search='bash_')
def test_params_search(self): self.assertEqual('search=bash_', utils.get_params(search='bash_'))
def test_params_showPaused_true(self): """Should detect True as default for showPaused""" self.assertEqual('', utils.get_params(showPaused=True))
def test_params_no_values(self): """Should return an empty string if no params are passed""" self.assertEquals('', utils.get_params())
def test_params_all(self): """Should return params string ordered by param key""" self.assertEqual('page=3&search=bash_&showPaused=False', utils.get_params(showPaused=False, page=3, search='bash_'))
def test_params_escape(self): self.assertEqual('search=%27%3E%22%2F%3E%3Cimg+src%3Dx+onerror%3Dalert%281%29%3E', utils.get_params(search="'>\"/><img src=x onerror=alert(1)>"))
def test_params_all(self): """Should return params string ordered by param key""" self.assertEqual( 'page=3&search=bash_&showPaused=False', utils.get_params(showPaused=False, page=3, search='bash_'))
def test_params_no_values(self): """Should return an empty string if no params are passed""" assert '' == utils.get_params()
def test_params_none_and_zero(self): query_str = utils.get_params(a=0, b=None, c='true') # The order won't be consistent, but that doesn't affect behaviour of a browser pairs = list(sorted(query_str.split('&'))) assert ['a=0', 'c=true'] == pairs
def test_params_escape(self): assert 'search=%27%3E%22%2F%3E%3Cimg+src%3Dx+onerror%3Dalert%281%29%3E' == utils.get_params( search="'>\"/><img src=x onerror=alert(1)>")