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

Side by Side Diff: appengine/swarming/server/task_request_test.py

Issue 2267363004: Add CIPD pin reporting to swarming. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: comments and some tests Created 4 years, 4 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 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import datetime 6 import datetime
7 import logging 7 import logging
8 import random 8 import random
9 import sys 9 import sys
10 import unittest 10 import unittest
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 self.assertEqual( 631 self.assertEqual(
632 datetime.datetime(2012, 1, 2, 3, 4, 5, 123000), 632 datetime.datetime(2012, 1, 2, 3, 4, 5, 123000),
633 task_request.request_key_to_datetime(key)) 633 task_request.request_key_to_datetime(key))
634 634
635 def test_request_id_to_key(self): 635 def test_request_id_to_key(self):
636 # Simple XOR. 636 # Simple XOR.
637 self.assertEqual( 637 self.assertEqual(
638 ndb.Key(task_request.TaskRequest, 0x7f14acec2fcfffff), 638 ndb.Key(task_request.TaskRequest, 0x7f14acec2fcfffff),
639 task_request.request_id_to_key(0xeb5313d0300000)) 639 task_request.request_id_to_key(0xeb5313d0300000))
640 640
641 def test_packages_grouped_by_path(self):
642 def cp(name, vers, path):
643 return task_request.CipdPackage(
644 package_name=name, version=vers, path=path)
645
646 deadbeef = 'deadbeef' * 5
647 badc0fee = 'badc0fee' * 5
648
649 ci = task_request.CipdInput(packages=[
650 cp('unpinned/${platform}', 'latest', 'a'),
651 cp('partial/windows-amd64', 'latest', 'b'),
652 cp('fully_specified/windows', deadbeef, 'b'),
653 ])
654
655 self.assertEqual(
656 ci.packages_grouped_by_path(None),
657 [
658 (
659 "a",
660 [
661 task_request.PinInfo(
662 pkg=cp('unpinned/${platform}', 'latest', 'a'), pin=None),
663 ]
664 ),
665 (
666 "b",
667 [
668 task_request.PinInfo(
669 pkg=cp('fully_specified/windows', deadbeef, 'b'), pin=None),
670 task_request.PinInfo(
671 pkg=cp('partial/windows-amd64', 'latest', 'b'), pin=None),
672 ]
673 )
674 ]
675 )
676
677 self.assertEqual(
678 ci.packages_grouped_by_path([
679 cp('unpinned/windows', 'instance_id1', 'a'),
680 cp('partial/windows-amd64', badc0fee, 'b'),
681 cp('fully_specified/windows', deadbeef, 'b'),
682 ]),
683 [
684 (
685 "a",
686 [
687 task_request.PinInfo(
688 pkg=cp('unpinned/${platform}', 'latest', 'a'),
689 pin=cp('unpinned/windows', 'instance_id1', 'a')),
690 ]
691 ),
692 (
693 "b",
694 [
695 task_request.PinInfo(
696 pkg=cp('fully_specified/windows', deadbeef, 'b'), pin=None),
697 task_request.PinInfo(
698 pkg=cp('partial/windows-amd64', 'latest', 'b'),
699 pin=cp(None, badc0fee, 'b')),
700 ]
701 )
702 ]
703 )
704
641 705
642 if __name__ == '__main__': 706 if __name__ == '__main__':
643 if '-v' in sys.argv: 707 if '-v' in sys.argv:
644 unittest.TestCase.maxDiff = None 708 unittest.TestCase.maxDiff = None
645 logging.basicConfig( 709 logging.basicConfig(
646 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 710 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
647 unittest.main() 711 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698