Skip to content

Commit

Permalink
Closes #23. Add test for _add_query_to_dashboard().
Browse files Browse the repository at this point in the history
  • Loading branch information
Marina Samuel committed Mar 8, 2018
1 parent 6356dee commit 5af7551
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions stmoab/tests/test_summary_dashboard.py
@@ -1,6 +1,8 @@
import json
from dateutil.parser import parse

from redash_client.constants import VizWidth, ChartType

from stmoab.tests.base import AppTest
from stmoab.SummaryDashboard import SummaryDashboard

Expand Down Expand Up @@ -293,3 +295,34 @@ def test_remove_all_graphs_success(self):
self.assertEqual(self.mock_requests_post.call_count, 2)
self.assertEqual(self.mock_requests_get.call_count, 2)
self.assertEqual(self.mock_requests_delete.call_count, 6)

def test_add_query_to_dashboard_makes_expected_calls(self):
QUERY_TITLE = "title"
QUERY_STRING = "SELECT * FROM test"

MAU_DAU_COLUMN_MAPPING = {
"a": "x",
"b": "y",
"c": "y",
"d": "y"
}

self.dash._add_query_to_dashboard(
QUERY_TITLE,
QUERY_STRING,
5,
VizWidth.WIDE,
column_mapping=MAU_DAU_COLUMN_MAPPING,
chart_type=ChartType.BAR
)

# POST calls:
# 1) Create dashboard
# 2) Create new query
# 3) Create new visualization
# 4) Add visualization to dashboard
# 5) Make dashboard public
# GET calls:
# 1) Create dashboard
self.assertEqual(self.mock_requests_post.call_count, 5)
self.assertEqual(self.mock_requests_get.call_count, 1)

0 comments on commit 5af7551

Please sign in to comment.