From c718d8be2b5bfbb2de14d53036488e506aa06f95 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Mon, 13 Apr 2020 15:37:30 +0100 Subject: [PATCH] [dashboard] Fix, improve test for custom filter --- tests/dashboards/api_tests.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/dashboards/api_tests.py b/tests/dashboards/api_tests.py index 1d2241e089197..ced4b3daca94f 100644 --- a/tests/dashboards/api_tests.py +++ b/tests/dashboards/api_tests.py @@ -192,7 +192,9 @@ def test_get_dashboards_custom_filter(self): arguments = { "filters": [ {"col": "dashboard_title", "opr": "title_or_slug", "value": "zy_"} - ] + ], + "order_column": "dashboard_title", + "order_direction": "asc", } self.login(username="admin") uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}" @@ -201,6 +203,17 @@ def test_get_dashboards_custom_filter(self): data = json.loads(rv.data.decode("utf-8")) self.assertEqual(data["count"], 3) + expected_response = [ + {"slug": "ZY_bar", "dashboard_title": "foo",}, + {"slug": "slug1zy_", "dashboard_title": "foo",}, + {"slug": "slug1", "dashboard_title": "zy_foo",}, + ] + for index, item in enumerate(data["result"]): + self.assertEqual(item["slug"], expected_response[index]["slug"]) + self.assertEqual( + item["dashboard_title"], expected_response[index]["dashboard_title"] + ) + self.logout() self.login(username="gamma") uri = f"api/v1/dashboard/?q={prison.dumps(arguments)}"