Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: dashboard/dashboard/group_report_test.py

Issue 2537053003: Changing group reports to use an id for multiple keys. (Closed)
Patch Set: added test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dashboard/dashboard/group_report.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/group_report_test.py
diff --git a/dashboard/dashboard/group_report_test.py b/dashboard/dashboard/group_report_test.py
index a2961209a85c83551c0d930e22477e38be138376..4006febc153ed7eaaa28b064ec168a9a34b8e218 100644
--- a/dashboard/dashboard/group_report_test.py
+++ b/dashboard/dashboard/group_report_test.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import json
import unittest
import webapp2
@@ -10,10 +11,12 @@ import webtest
from google.appengine.ext import ndb
from dashboard import group_report
+from dashboard import short_uri
from dashboard.common import testing_common
from dashboard.common import utils
from dashboard.models import anomaly
from dashboard.models import bug_data
+from dashboard.models import page_state
from dashboard.models import sheriff
from dashboard.models import stoppage_alert
@@ -93,6 +96,31 @@ class GroupReportTest(testing_common.TestCase):
# but not the non-overlapping alert.
self.assertEqual(5, len(alert_list))
+ def testPost_WithInvalidSidParameter_ShowsError(self):
+ response = self.testapp.post('/group_report?sid=foobar')
+ error = self.GetJsonValue(response, 'error')
+ self.assertIn('No anomalies specified', error)
+
+ def testPost_WithValidSidParameter(self):
+ sheriff_key = self._AddSheriff()
+ test_keys = self._AddTests()
+ selected_ranges = [(400, 900), (200, 700)]
+ selected_keys = self._AddAnomalyEntities(
+ selected_ranges, test_keys[0], sheriff_key)
+
+ json_keys = json.dumps(selected_keys)
+ state_id = short_uri.GenerateHash(','.join(selected_keys))
+ page_state.PageState(id=state_id, value=json_keys).put()
+
+ response = self.testapp.post('/group_report?sid=%s' % state_id)
+ alert_list = self.GetJsonValue(response, 'alert_list')
+
+ self.assertEqual(unicode(selected_keys[1], 'utf-8'),
+ alert_list[0].get('key'))
+ self.assertEqual(unicode(selected_keys[0], 'utf-8'),
+ alert_list[1].get('key'))
+ self.assertEqual(2, len(alert_list))
+
def testPost_WithKeyOfNonExistentAlert_ShowsError(self):
key = ndb.Key('Anomaly', 123)
response = self.testapp.post('/group_report?keys=%s' % key.urlsafe())
« no previous file with comments | « dashboard/dashboard/group_report.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698