Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 dashboard import add_histograms_queue | 9 from dashboard import add_histograms_queue |
| 10 from dashboard.common import testing_common | 10 from dashboard.common import testing_common |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 class AddHistogramsQueueTest(testing_common.TestCase): | 24 class AddHistogramsQueueTest(testing_common.TestCase): |
| 25 def setUp(self): | 25 def setUp(self): |
| 26 super(AddHistogramsQueueTest, self).setUp() | 26 super(AddHistogramsQueueTest, self).setUp() |
| 27 app = webapp2.WSGIApplication([ | 27 app = webapp2.WSGIApplication([ |
| 28 ('/add_histograms_queue', | 28 ('/add_histograms_queue', |
| 29 add_histograms_queue.AddHistogramsQueueHandler)]) | 29 add_histograms_queue.AddHistogramsQueueHandler)]) |
| 30 self.testapp = webtest.TestApp(app) | 30 self.testapp = webtest.TestApp(app) |
| 31 self.SetCurrentUser('foo@bar.com', is_admin=True) | 31 self.SetCurrentUser('foo@bar.com', is_admin=True) |
| 32 | 32 |
| 33 def testPost(self): | 33 def testPost(self): |
|
shatch
2017/05/16 15:47:44
Add tests covering _GetOrCreateAncestors call, ver
eakuefner
2017/05/19 18:51:48
Done, by adding more asserts here.
| |
| 34 test_path = 'Chromium/win7/suite/metric' | 34 test_path = 'Chromium/win7/suite/metric' |
| 35 params = { | 35 params = { |
| 36 'data': TEST_HISTOGRAM, | 36 'data': TEST_HISTOGRAM, |
| 37 'test_path': test_path, | 37 'test_path': test_path, |
| 38 'revision': 123 | 38 'revision': 123 |
| 39 } | 39 } |
| 40 test_key = utils.TestKey(test_path) | 40 test_key = utils.TestKey(test_path) |
| 41 self.testapp.post('/add_histograms_queue', params) | 41 self.testapp.post('/add_histograms_queue', params) |
| 42 | 42 |
| 43 original_histogram = json.loads(TEST_HISTOGRAM) | 43 original_histogram = json.loads(TEST_HISTOGRAM) |
| 44 | 44 |
| 45 test = test_key.get() | |
| 46 self.assertIsNotNone(test) | |
| 47 | |
| 45 histograms = histogram.Histogram.query().fetch() | 48 histograms = histogram.Histogram.query().fetch() |
| 46 self.assertEqual(1, len(histograms)) | 49 self.assertEqual(1, len(histograms)) |
| 47 self.assertEqual(original_histogram['guid'], histograms[0].key.id()) | 50 self.assertEqual(original_histogram['guid'], histograms[0].key.id()) |
| 48 | 51 |
| 49 h = histograms[0] | 52 h = histograms[0] |
| 50 self.assertEqual(TEST_HISTOGRAM, h.data) | 53 self.assertEqual(TEST_HISTOGRAM, h.data) |
| 51 self.assertEqual(test_key, h.test) | 54 self.assertEqual(test_key, h.test) |
| 52 self.assertEqual(123, h.revision) | 55 self.assertEqual(123, h.revision) |
| OLD | NEW |