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

Side by Side Diff: appengine/chromium_cq_status/handlers/test/patch_summary_test.py

Issue 1877453003: Only try to compute running_all_jobs time if we know when try-job verifier started (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added tests Created 4 years, 8 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 from datetime import datetime 5 from datetime import datetime
6 import json 6 import json
7 import logging 7 import logging
8 import os 8 import os
9 9
10 from third_party.testing_utils import testing 10 from third_party.testing_utils import testing
11 11
12 import main 12 import main
13 from model.record import Record 13 from model.record import Record
14 14
15 15
16 class PatchSummaryTest(testing.AppengineTestCase): 16 class PatchSummaryTest(testing.AppengineTestCase):
17 app_module = main.app 17 app_module = main.app
18 18
19 def test_patch_summary_simple(self): 19 def test_patch_summary_simple(self):
20 return self._test_patch('simple') 20 return self._test_patch('simple')
21 21
22 def test_patch_summary_flaky(self): 22 def test_patch_summary_flaky(self):
23 return self._test_patch('flaky') 23 return self._test_patch('flaky')
24 24
25 def test_no_verifier_start(self):
26 return self._test_patch('no_verifier_start')
27
25 # TODO(sergeyberezin): add a small real-life CL for an integration 28 # TODO(sergeyberezin): add a small real-life CL for an integration
26 # test. 29 # test.
27 30
28 def _load_records(self, filename): 31 def _load_records(self, filename):
29 assert Record.query().count() == 0 32 assert Record.query().count() == 0
30 records = _load_json(filename) 33 records = _load_json(filename)
31 for record in records: 34 for record in records:
32 self.mock_now(datetime.utcfromtimestamp(record['timestamp'])) 35 self.mock_now(datetime.utcfromtimestamp(record['timestamp']))
33 Record( 36 Record(
34 id=record['key'], 37 id=record['key'],
35 tags=record['tags'], 38 tags=record['tags'],
36 fields=record['fields'], 39 fields=record['fields'],
37 ).put() 40 ).put()
38 41
39 def _test_patch(self, name, issue=123456789): 42 def _test_patch(self, name, issue=123456789):
40 self._load_records('patch_%s.json' % name) 43 self._load_records('patch_%s.json' % name)
41 response = self.test_app.get('/patch-summary/%s/1' % issue) 44 response = self.test_app.get('/patch-summary/%s/1' % issue)
42 summary = json.loads(response.body) 45 summary = json.loads(response.body)
43 logging.debug(json.dumps(summary, indent=2)) 46 logging.debug(json.dumps(summary, indent=2))
44 return summary 47 return summary
45 48
46 49
47 def _load_json(filename): 50 def _load_json(filename):
48 path = os.path.join(os.path.dirname(__file__), 'resources', filename) 51 path = os.path.join(os.path.dirname(__file__), 'resources', filename)
49 return json.loads(open(path).read()) 52 return json.loads(open(path).read())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698