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

Side by Side Diff: appengine/swarming/handlers_endpoints_test.py

Issue 2832203002: task_queues: Add more scaffolding (Closed)
Patch Set: Addressed comments Created 3 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
« no previous file with comments | « appengine/swarming/handlers_backend.py ('k') | appengine/swarming/handlers_test.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright 2015 The LUCI Authors. All rights reserved. 3 # Copyright 2015 The LUCI Authors. All rights reserved.
4 # Use of this source code is governed under the Apache License, Version 2.0 4 # Use of this source code is governed under the Apache License, Version 2.0
5 # that can be found in the LICENSE file. 5 # that can be found in the LICENSE file.
6 6
7 import base64 7 import base64
8 import datetime 8 import datetime
9 import json 9 import json
10 import logging 10 import logging
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1168
1169 start = ( 1169 start = (
1170 utils.datetime_to_timestamp(now - datetime.timedelta(days=1)) / 1170 utils.datetime_to_timestamp(now - datetime.timedelta(days=1)) /
1171 1000000.) 1171 1000000.)
1172 end = ( 1172 end = (
1173 utils.datetime_to_timestamp(now + datetime.timedelta(days=1)) / 1173 utils.datetime_to_timestamp(now + datetime.timedelta(days=1)) /
1174 1000000.) 1174 1000000.)
1175 self.set_as_privileged_user() 1175 self.set_as_privileged_user()
1176 return first, second, str_now_120, start, end 1176 return first, second, str_now_120, start, end
1177 1177
1178
1179 def _gen_three_pending_tasks(self): 1178 def _gen_three_pending_tasks(self):
1180 # Creates three pending tasks, spaced 1 minute apart 1179 # Creates three pending tasks, spaced 1 minute apart
1181 now = datetime.datetime(2010, 1, 2, 3, 4, 5) 1180 now = datetime.datetime(2010, 1, 2, 3, 4, 5)
1182 self.mock_now(now) 1181 self.mock_now(now)
1183 self.mock(random, 'getrandbits', lambda _: 0x66) 1182 self.mock(random, 'getrandbits', lambda _: 0x66)
1184 _, first_id = self.client_create_task_raw( 1183 _, first_id = self.client_create_task_raw(
1185 name='first', tags=['project:yay', 'commit:abcd', 'os:Win'], 1184 name='first', tags=['project:yay', 'commit:abcd', 'os:Win'],
1186 pubsub_topic='projects/abc/topics/def', 1185 pubsub_topic='projects/abc/topics/def',
1187 pubsub_userdata='1234', 1186 pubsub_userdata='1234',
1188 properties=dict(idempotent=True)) 1187 properties=dict(idempotent=True))
(...skipping 10 matching lines...) Expand all
1199 now_120 = self.mock_now(now, 120) 1198 now_120 = self.mock_now(now, 120)
1200 _, third_id = self.client_create_task_raw( 1199 _, third_id = self.client_create_task_raw(
1201 name='third', user='jack@localhost', 1200 name='third', user='jack@localhost',
1202 pubsub_topic='projects/abc/topics/def', 1201 pubsub_topic='projects/abc/topics/def',
1203 pubsub_userdata='9000', 1202 pubsub_userdata='9000',
1204 tags=['project:yay', 'commit:ijkhl', 'os:Linux'], 1203 tags=['project:yay', 'commit:ijkhl', 'os:Linux'],
1205 properties=dict(idempotent=True)) 1204 properties=dict(idempotent=True))
1206 1205
1207 return first_id, second_id, third_id, now, now_60, now_120 1206 return first_id, second_id, third_id, now, now_60, now_120
1208 1207
1208
1209 class TaskApiTest(BaseTest): 1209 class TaskApiTest(BaseTest):
1210 api_service_cls = handlers_endpoints.SwarmingTaskService 1210 api_service_cls = handlers_endpoints.SwarmingTaskService
1211 1211
1212 def setUp(self): 1212 def setUp(self):
1213 super(TaskApiTest, self).setUp() 1213 super(TaskApiTest, self).setUp()
1214 self.tasks_api = test_case.Endpoints( 1214 self.tasks_api = test_case.Endpoints(
1215 handlers_endpoints.SwarmingTasksService) 1215 handlers_endpoints.SwarmingTasksService)
1216 1216
1217 def test_cancel_ok(self): 1217 def test_cancel_ok(self):
1218 """Asserts that task cancellation goes smoothly.""" 1218 """Asserts that task cancellation goes smoothly."""
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 self.call_api('terminate', body={'bot_id': 'bot1'}, status=403) 2184 self.call_api('terminate', body={'bot_id': 'bot1'}, status=403)
2185 2185
2186 2186
2187 if __name__ == '__main__': 2187 if __name__ == '__main__':
2188 if '-v' in sys.argv: 2188 if '-v' in sys.argv:
2189 unittest.TestCase.maxDiff = None 2189 unittest.TestCase.maxDiff = None
2190 logging.basicConfig(level=logging.DEBUG) 2190 logging.basicConfig(level=logging.DEBUG)
2191 else: 2191 else:
2192 logging.basicConfig(level=logging.CRITICAL) 2192 logging.basicConfig(level=logging.CRITICAL)
2193 unittest.main() 2193 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_backend.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698