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

Side by Side Diff: dashboard/dashboard/add_histograms_queue_test.py

Issue 2879453002: [Dashboard] Get or create ancestors in add_histograms_queue (Closed)
Patch Set: actually add new add_point_queue test Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « dashboard/dashboard/add_histograms_queue.py ('k') | dashboard/dashboard/add_point_queue.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import webapp2 6 import webapp2
7 import webtest 7 import webtest
8 8
9 from google.appengine.ext import ndb
10
9 from dashboard import add_histograms_queue 11 from dashboard import add_histograms_queue
10 from dashboard.common import testing_common 12 from dashboard.common import testing_common
11 from dashboard.common import utils 13 from dashboard.common import utils
14 from dashboard.models import anomaly
15 from dashboard.models import graph_data
12 from dashboard.models import histogram 16 from dashboard.models import histogram
13 17
14 18
15 19
16 TEST_HISTOGRAM = json.dumps({ 20 TEST_HISTOGRAM = json.dumps({
17 'guid': 'a5dd1360-fed5-4872-9f0e-c1c079b2ae26', 21 'guid': 'a5dd1360-fed5-4872-9f0e-c1c079b2ae26',
18 'binBoundaries': [1, [1, 1000, 20]], 22 'binBoundaries': [1, [1, 1000, 20]],
19 'name': 'foo', 23 'name': 'foo',
20 'unit': 'count' 24 'unit': 'count_biggerIsBetter'
21 }) 25 })
22 26
23 27
24 class AddHistogramsQueueTest(testing_common.TestCase): 28 class AddHistogramsQueueTest(testing_common.TestCase):
25 def setUp(self): 29 def setUp(self):
26 super(AddHistogramsQueueTest, self).setUp() 30 super(AddHistogramsQueueTest, self).setUp()
27 app = webapp2.WSGIApplication([ 31 app = webapp2.WSGIApplication([
28 ('/add_histograms_queue', 32 ('/add_histograms_queue',
29 add_histograms_queue.AddHistogramsQueueHandler)]) 33 add_histograms_queue.AddHistogramsQueueHandler)])
30 self.testapp = webtest.TestApp(app) 34 self.testapp = webtest.TestApp(app)
31 self.SetCurrentUser('foo@bar.com', is_admin=True) 35 self.SetCurrentUser('foo@bar.com', is_admin=True)
32 36
33 def testPost(self): 37 def testPost(self):
sh 2017/05/19 19:10:27 Add a test for a diagnostic?
eakuefner 2017/05/22 21:22:28 Done.
34 test_path = 'Chromium/win7/suite/metric' 38 test_path = 'Chromium/win7/suite/metric'
35 params = { 39 params = {
36 'data': TEST_HISTOGRAM, 40 'data': TEST_HISTOGRAM,
37 'test_path': test_path, 41 'test_path': test_path,
38 'revision': 123 42 'revision': 123
39 } 43 }
40 test_key = utils.TestKey(test_path)
41 self.testapp.post('/add_histograms_queue', params) 44 self.testapp.post('/add_histograms_queue', params)
42 45
46 test_key = utils.TestKey(test_path)
43 original_histogram = json.loads(TEST_HISTOGRAM) 47 original_histogram = json.loads(TEST_HISTOGRAM)
44 48
49 test = test_key.get()
50 self.assertEqual(test.units, 'count_biggerIsBetter')
sh 2017/05/19 19:10:27 Tests for the different units cases?
eakuefner 2017/05/22 21:22:28 Added test coverage for GetUnitArgs directly.
51 self.assertEqual(test.improvement_direction, anomaly.UP)
52
53 master = ndb.Key('Master', 'Chromium').get()
54 self.assertIsNotNone(master)
55
56 bot = ndb.Key('Master', 'Chromium', 'Bot', 'win7').get()
57 self.assertIsNotNone(bot)
58
59 tests = graph_data.TestMetadata.query().fetch()
60 self.assertEqual(2, len(tests))
61
45 histograms = histogram.Histogram.query().fetch() 62 histograms = histogram.Histogram.query().fetch()
46 self.assertEqual(1, len(histograms)) 63 self.assertEqual(1, len(histograms))
47 self.assertEqual(original_histogram['guid'], histograms[0].key.id()) 64 self.assertEqual(original_histogram['guid'], histograms[0].key.id())
48 65
49 h = histograms[0] 66 h = histograms[0]
50 self.assertEqual(TEST_HISTOGRAM, h.data) 67 self.assertEqual(TEST_HISTOGRAM, h.data)
51 self.assertEqual(test_key, h.test) 68 self.assertEqual(test_key, h.test)
52 self.assertEqual(123, h.revision) 69 self.assertEqual(123, h.revision)
OLDNEW
« no previous file with comments | « dashboard/dashboard/add_histograms_queue.py ('k') | dashboard/dashboard/add_point_queue.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698