Add test for ActivityStreamExperimentDashboard initialization.
This commit is contained in:
Родитель
6e13e96f9e
Коммит
df0481038e
1
Makefile
1
Makefile
|
@ -6,6 +6,7 @@ lint:
|
|||
flake8 src/tests/base.py
|
||||
flake8 src/tests/test_redash.py
|
||||
flake8 src/tests/test_summary_dashboard.py
|
||||
flake8 src/tests/test_activity_stream_experiment_dashboard.py
|
||||
|
||||
test: lint
|
||||
nosetests --with-coverage --cover-package=src
|
||||
|
|
|
@ -23,7 +23,7 @@ class ActivityStreamExperimentDashboard(SummaryDashboard):
|
|||
DEFAULT_EVENTS = ["CLICK", "SEARCH", "BLOCK", "DELETE", "BOOKMARK_ADD",
|
||||
"CLEAR_HISTORY", {
|
||||
"event_name": "Positive Interactions",
|
||||
"event_list": ['CLICK', 'BOOKMARK_ADD', 'SEARCH']}]
|
||||
"event_list": ["CLICK", "BOOKMARK_ADD", "SEARCH"]}]
|
||||
MASGA_EVENTS = ["HIDE_LOADER", "SHOW_LOADER", "MISSING_IMAGE",
|
||||
"SLOW_ADDON_DETECTED"]
|
||||
ALPHA_ERROR = 0.005
|
||||
|
|
|
@ -7,7 +7,7 @@ from src.samples.SummaryDashboard import SummaryDashboard
|
|||
|
||||
class AppTest(unittest.TestCase):
|
||||
|
||||
def get_summary_dashboard(self, api_key):
|
||||
def get_dashboard(self, api_key):
|
||||
EVENTS_TABLE_NAME = "activity_stream_mobile_events_daily"
|
||||
START_DATE = "02/17/2017"
|
||||
DASH_NAME = "Firefox iOS: Metrics Summary"
|
||||
|
@ -40,7 +40,7 @@ class AppTest(unittest.TestCase):
|
|||
self.mock_requests_delete = mock_requests_delete_patcher.start()
|
||||
self.addCleanup(mock_requests_delete_patcher.stop)
|
||||
|
||||
self.dash = self.get_summary_dashboard(API_KEY)
|
||||
self.dash = self.get_dashboard(API_KEY)
|
||||
|
||||
def get_mock_response(self, status=200, content='{}'):
|
||||
mock_response = mock.Mock()
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
from src.tests.base import AppTest
|
||||
from samples.ActivityStreamExperimentDashboard import (
|
||||
ActivityStreamExperimentDashboard)
|
||||
|
||||
|
||||
class TestActivityStreamExperimentDashboard(AppTest):
|
||||
|
||||
ADDON_VERSIONS = ["1.8.0", "1.9.0"]
|
||||
START_DATE = "02/17/2017"
|
||||
DASH_PREFIX = "Activity Stream A/B Testing: {0}"
|
||||
DASH_NAME = "Screenshots Long Cache"
|
||||
EXPERIMENT_ID = "exp-014-screenshotsasync"
|
||||
|
||||
def get_dashboard(self, api_key):
|
||||
self.mock_requests_get.return_value = self.get_mock_response()
|
||||
self.mock_requests_post.return_value = self.get_mock_response()
|
||||
|
||||
dashboard = ActivityStreamExperimentDashboard(
|
||||
self.redash,
|
||||
self.DASH_NAME,
|
||||
self.EXPERIMENT_ID,
|
||||
self.ADDON_VERSIONS,
|
||||
self.START_DATE,
|
||||
)
|
||||
return dashboard
|
||||
|
||||
def test_correct_values_at_initialization(self):
|
||||
self.assertEqual(self.dash._experiment_id, self.EXPERIMENT_ID)
|
||||
self.assertEqual(
|
||||
self.dash._dash_name, self.DASH_PREFIX.format(self.DASH_NAME))
|
||||
self.assertEqual(self.dash._start_date, self.START_DATE)
|
||||
self.assertEqual(self.dash.addon_versions, "'1.8.0', '1.9.0'")
|
||||
|
||||
self.assertEqual(self.mock_requests_post.call_count, 1)
|
||||
self.assertEqual(self.mock_requests_get.call_count, 1)
|
||||
self.assertEqual(self.mock_requests_delete.call_count, 0)
|
Загрузка…
Ссылка в новой задаче