Closes #2: Don't pass an instance of RedashClient to construct dashboards.

This commit is contained in:
Marina Samuel 2018-02-05 16:19:12 -05:00
Родитель d7a55a736d
Коммит a9727eebe9
8 изменённых файлов: 14 добавлений и 20 удалений

Просмотреть файл

@ -8,4 +8,4 @@
St. Moab
====================
A tool for automating a/b testing analysis using stmo dashboards (https://sql.telemetry.mozilla.org)
A tool for automating a/b testing analysis using stmo dashboards (https://sql.telemetry.mozilla.org)

Просмотреть файл

@ -37,12 +37,12 @@ class ActivityStreamExperimentDashboard(SummaryDashboard):
DISABLE_TITLE = "Disable Rate"
RETENTION_DIFF_TITLE = "Daily Retention Difference (Experiment - Control)"
def __init__(self, redash_client, project_name, dash_name, exp_id,
def __init__(self, api_key, project_name, dash_name, exp_id,
start_date=None, end_date=None):
DASH_TITLE = "{project}: {dash}".format(
project=project_name, dash=dash_name)
super(ActivityStreamExperimentDashboard, self).__init__(
redash_client,
api_key,
DASH_TITLE,
self.DEFAULT_EVENTS_TABLE,
start_date, end_date)

Просмотреть файл

@ -25,12 +25,12 @@ class StatisticalDashboard(ActivityStreamExperimentDashboard):
def __init__(
self, redash_client, aws_access_key, aws_secret_key,
self, api_key, aws_access_key, aws_secret_key,
s3_bucket_id, project_name, dash_name, exp_id,
start_date=None, end_date=None
):
super(StatisticalDashboard, self).__init__(
redash_client,
api_key,
project_name,
dash_name,
exp_id,

Просмотреть файл

@ -1,5 +1,6 @@
import time
from redash_client.client import RedashClient
from redash_client.constants import (
VizWidth, VizType, ChartType, TimeInterval)
@ -37,7 +38,7 @@ class SummaryDashboard(object):
class SummaryDashboardException(Exception):
pass
def __init__(self, redash_client, dash_name, events_table_name,
def __init__(self, api_key, dash_name, events_table_name,
start_date, end_date=None):
self._dash_name = dash_name
self._events_table = events_table_name
@ -48,7 +49,7 @@ class SummaryDashboard(object):
"end_date": self._end_date
}
self.redash = redash_client
self.redash = RedashClient(api_key)
self._dash_id = self.redash.create_new_dashboard(self._dash_name)
self.redash.publish_dashboard(self._dash_id)
self.public_url = self.redash.get_public_url(self._dash_id)

Просмотреть файл

@ -1,7 +1,5 @@
import os
from redash_client.client import RedashClient
from stmoab.StatisticalDashboard import StatisticalDashboard
'''
@ -179,14 +177,12 @@ if __name__ == '__main__':
aws_secret_key = os.environ['AWS_SECRET_KEY']
s3_bucket_id_stats = os.environ['S3_BUCKET_ID_STATS']
redash_client = RedashClient(api_key)
PING_CENTRE_TTABLE = "Statistical Analysis - Ping Centre"
UT_TTABLE = "Statistical Analysis - UT"
UT_HOURLY_TTABLE = "Statistical Analysis (Per Active Hour) - UT"
dash = StatisticalDashboard(
redash_client,
api_key,
"Activity Stream System Addon Experiment",
"57 Release",
"pref-flip-activity-stream-57-release-enabled-existing-users-bug-1415966",

Просмотреть файл

@ -2,7 +2,6 @@ import mock
import json
import unittest
from redash_client.client import RedashClient
from stmoab.SummaryDashboard import SummaryDashboard
@ -39,7 +38,7 @@ class AppTest(unittest.TestCase):
self.mock_requests_post.return_value = self.get_mock_response()
dashboard = SummaryDashboard(
self.redash,
self.API_KEY,
DASH_NAME,
EVENTS_TABLE_NAME,
START_DATE,
@ -47,9 +46,7 @@ class AppTest(unittest.TestCase):
return dashboard
def setUp(self):
API_KEY = "test_key"
self.redash = RedashClient(API_KEY)
self.API_KEY = "test_key"
mock_requests_post_patcher = mock.patch(
"redash_client.client.requests.post")
@ -66,7 +63,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_dashboard(API_KEY)
self.dash = self.get_dashboard(self.API_KEY)
def get_mock_response(self, status=200, content='{}'):
mock_response = mock.Mock()

Просмотреть файл

@ -19,7 +19,7 @@ class TestActivityStreamExperimentDashboard(AppTest):
self.mock_requests_post.return_value = self.get_mock_response()
dashboard = ActivityStreamExperimentDashboard(
self.redash,
self.API_KEY,
self.DASH_PROJECT,
self.DASH_NAME,
self.EXPERIMENT_ID,

Просмотреть файл

@ -29,7 +29,7 @@ class TestStatisticalDashboard(AppTest):
self.addCleanup(mock_boto_transfer_patcher.stop)
dashboard = StatisticalDashboard(
self.redash,
self.API_KEY,
self.AWS_ACCESS_KEY,
self.AWS_SECRET_KEY,
self.AWS_BUCKET_ID,