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

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

Issue 1939343002: swarming: change meaning of inputs_ref (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: nit Created 4 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
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 by the Apache v2.0 license that can be 4 # Use of this source code is governed by the Apache v2.0 license that can be
5 # found in the LICENSE file. 5 # 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 u'priority:200', 498 u'priority:200',
499 u'user:joe@localhost', 499 u'user:joe@localhost',
500 ], 500 ],
501 u'user': u'joe@localhost', 501 u'user': u'joe@localhost',
502 }, 502 },
503 u'task_id': u'5cee488008810', 503 u'task_id': u'5cee488008810',
504 } 504 }
505 response = self.call_api('new', body=message_to_dict(request)) 505 response = self.call_api('new', body=message_to_dict(request))
506 self.assertEqual(expected, response.json) 506 self.assertEqual(expected, response.json)
507 507
508 def test_new_ok_isolated_output(self):
509 """Asserts that new generates appropriate metadata."""
510 self.mock(random, 'getrandbits', lambda _: 0x88)
511 now = datetime.datetime(2010, 1, 2, 3, 4, 5)
512 self.mock_now(now)
513 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
514 request = swarming_rpcs.NewTaskRequest(
515 expiration_secs=30,
516 name='job1',
517 priority=200,
518 properties=swarming_rpcs.TaskProperties(
519 command=['rm', '-rf', '/'],
520 dimensions=[
521 swarming_rpcs.StringPair(key='pool', value='default'),
522 swarming_rpcs.StringPair(key='foo', value='bar'),
523 ],
524 env=[
525 swarming_rpcs.StringPair(key='PATH', value='/'),
526 ],
527 execution_timeout_secs=30,
528 io_timeout_secs=30,
529 outputs_target=swarming_rpcs.IsolatedOutputsTarget(
530 isolatedserver='http://localhost:1',
531 namespace='default-gzip')),
532 tags=['foo:bar'],
533 user='joe@localhost')
534 expected = {
535 u'request': {
536 u'authenticated': u'user:user@example.com',
537 u'created_ts': str_now,
538 u'expiration_secs': u'30',
539 u'name': u'job1',
540 u'priority': u'200',
541 u'properties': {
542 u'command': [u'rm', u'-rf', u'/'],
543 u'dimensions': [
544 {u'key': u'foo', u'value': u'bar'},
545 {u'key': u'pool', u'value': u'default'},
546 ],
547 u'env': [
548 {u'key': u'PATH', u'value': u'/'},
549 ],
550 u'execution_timeout_secs': u'30',
551 u'grace_period_secs': u'30',
552 u'idempotent': False,
553 u'io_timeout_secs': u'30',
554 u'outputs_target': {
555 'isolatedserver': 'http://localhost:1',
556 'namespace': 'default-gzip',
557 },
558 },
559 u'tags': [
560 u'foo:bar',
561 u'pool:default',
562 u'priority:200',
563 u'user:joe@localhost',
564 ],
565 u'user': u'joe@localhost',
566 },
567 u'task_id': u'5cee488008810',
568 }
569 response = self.call_api('new', body=message_to_dict(request))
570 self.assertEqual(expected, response.json)
571
508 def test_list_ok(self): 572 def test_list_ok(self):
509 """Asserts that list requests all TaskResultSummaries.""" 573 """Asserts that list requests all TaskResultSummaries."""
510 first, second, str_now_120, start, end = self._gen_two_tasks() 574 first, second, str_now_120, start, end = self._gen_two_tasks()
511 first_no_perf = first.copy() 575 first_no_perf = first.copy()
512 first_no_perf.pop('performance_stats') 576 first_no_perf.pop('performance_stats')
513 # Basic request. 577 # Basic request.
514 request = swarming_rpcs.TasksRequest( 578 request = swarming_rpcs.TasksRequest(
515 end=end, start=start, include_performance_stats=True) 579 end=end, start=start, include_performance_stats=True)
516 expected = {u'now': str_now_120, u'items': [second, first]} 580 expected = {u'now': str_now_120, u'items': [second, first]}
517 actual = self.call_api('list', body=message_to_dict(request)).json 581 actual = self.call_api('list', body=message_to_dict(request)).json
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 self.assertEqual(expected, response.json) 1427 self.assertEqual(expected, response.json)
1364 1428
1365 1429
1366 if __name__ == '__main__': 1430 if __name__ == '__main__':
1367 if '-v' in sys.argv: 1431 if '-v' in sys.argv:
1368 unittest.TestCase.maxDiff = None 1432 unittest.TestCase.maxDiff = None
1369 logging.basicConfig(level=logging.DEBUG) 1433 logging.basicConfig(level=logging.DEBUG)
1370 else: 1434 else:
1371 logging.basicConfig(level=logging.CRITICAL) 1435 logging.basicConfig(level=logging.CRITICAL)
1372 unittest.main() 1436 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698