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

Side by Side Diff: scripts/master/buildbucket/unittests/integration_test.py

Issue 2157703002: buildbucket: support unique change urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: nits Created 4 years, 5 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Buildbucket integration unit tests""" 6 """Buildbucket integration unit tests"""
7 7
8 import contextlib 8 import contextlib
9 import datetime 9 import datetime
10 import httplib 10 import httplib
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 self.changes.get_source_stamp.return_value = self.ssid 115 self.changes.get_source_stamp.return_value = self.ssid
116 116
117 @contextlib.contextmanager 117 @contextlib.contextmanager
118 def create_integrator(self, buildbot=None, max_lease_count=None, 118 def create_integrator(self, buildbot=None, max_lease_count=None,
119 build_params_hook=None): 119 build_params_hook=None):
120 self.buildbucket = fake_buildbucket() 120 self.buildbucket = fake_buildbucket()
121 self.buildbot = buildbot or fake_buildbot() 121 self.buildbot = buildbot or fake_buildbot()
122 self.integrator = integration.BuildBucketIntegrator( 122 self.integrator = integration.BuildBucketIntegrator(
123 self.buckets, max_lease_count=max_lease_count, 123 self.buckets, max_lease_count=max_lease_count,
124 build_params_hook=build_params_hook, 124 build_params_hook=build_params_hook,
125 heartbeat_interval=datetime.timedelta(microseconds=1)) 125 heartbeat_interval=datetime.timedelta(microseconds=1),
126 change_store_factory=lambda bb: self.changes)
126 def log(msg, level=logging.INFO): 127 def log(msg, level=logging.INFO):
127 logging.log(level, msg) 128 logging.log(level, msg)
128 self.integrator.log = log 129 self.integrator.log = log
129 self.integrator.start( 130 self.integrator.start(self.buildbot, self.buildbucket)
130 self.buildbot, self.buildbucket,
131 change_store_factory=lambda bb: self.changes)
132 try: 131 try:
133 yield 132 yield
134 finally: 133 finally:
135 self.integrator.stop() 134 self.integrator.stop()
136 135
137 def test_no_builds(self): 136 def test_no_builds(self):
138 with self.create_integrator(): 137 with self.create_integrator():
139 self.buildbucket.api.peek.return_value = {'builds': []} 138 self.buildbucket.api.peek.return_value = {'builds': []}
140 run_deferred(self.integrator.poll_builds()) 139 run_deferred(self.integrator.poll_builds())
141 self.assertFalse(self.buildbot.add_build_request.called) 140 self.assertFalse(self.buildbot.add_build_request.called)
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 self.assertFalse(build.id in self.integrator._leases) 618 self.assertFalse(build.id in self.integrator._leases)
620 self.assertFalse(self.buildbucket.api.fail.called) 619 self.assertFalse(self.buildbucket.api.fail.called)
621 620
622 621
623 if __name__ == '__main__': 622 if __name__ == '__main__':
624 logging.basicConfig( 623 logging.basicConfig(
625 level=(logging.DEBUG if '-v' in sys.argv else logging.FATAL)) 624 level=(logging.DEBUG if '-v' in sys.argv else logging.FATAL))
626 if '-v' in sys.argv: 625 if '-v' in sys.argv:
627 unittest.TestCase.maxDiff = None 626 unittest.TestCase.maxDiff = None
628 unittest.main() 627 unittest.main()
OLDNEW
« no previous file with comments | « scripts/master/buildbucket/unittests/changestore_test.py ('k') | scripts/master/master_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698