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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/server/task_request_test.py
diff --git a/appengine/swarming/server/task_request_test.py b/appengine/swarming/server/task_request_test.py
index 73032b0b350c032e32065eb962d1091afdd926aa..361c5ce43b52c8279b7bdb3e8c04d15fa402a788 100755
--- a/appengine/swarming/server/task_request_test.py
+++ b/appengine/swarming/server/task_request_test.py
@@ -638,6 +638,70 @@ class TaskRequestApiTest(TestCase):
ndb.Key(task_request.TaskRequest, 0x7f14acec2fcfffff),
task_request.request_id_to_key(0xeb5313d0300000))
+ def test_packages_grouped_by_path(self):
+ def cp(name, vers, path):
+ return task_request.CipdPackage(
+ package_name=name, version=vers, path=path)
+
+ deadbeef = 'deadbeef' * 5
+ badc0fee = 'badc0fee' * 5
+
+ ci = task_request.CipdInput(packages=[
+ cp('unpinned/${platform}', 'latest', 'a'),
+ cp('partial/windows-amd64', 'latest', 'b'),
+ cp('fully_specified/windows', deadbeef, 'b'),
+ ])
+
+ self.assertEqual(
+ ci.packages_grouped_by_path(None),
+ [
+ (
+ "a",
+ [
+ task_request.PinInfo(
+ pkg=cp('unpinned/${platform}', 'latest', 'a'), pin=None),
+ ]
+ ),
+ (
+ "b",
+ [
+ task_request.PinInfo(
+ pkg=cp('fully_specified/windows', deadbeef, 'b'), pin=None),
+ task_request.PinInfo(
+ pkg=cp('partial/windows-amd64', 'latest', 'b'), pin=None),
+ ]
+ )
+ ]
+ )
+
+ self.assertEqual(
+ ci.packages_grouped_by_path([
+ cp('unpinned/windows', 'instance_id1', 'a'),
+ cp('partial/windows-amd64', badc0fee, 'b'),
+ cp('fully_specified/windows', deadbeef, 'b'),
+ ]),
+ [
+ (
+ "a",
+ [
+ task_request.PinInfo(
+ pkg=cp('unpinned/${platform}', 'latest', 'a'),
+ pin=cp('unpinned/windows', 'instance_id1', 'a')),
+ ]
+ ),
+ (
+ "b",
+ [
+ task_request.PinInfo(
+ pkg=cp('fully_specified/windows', deadbeef, 'b'), pin=None),
+ task_request.PinInfo(
+ pkg=cp('partial/windows-amd64', 'latest', 'b'),
+ pin=cp(None, badc0fee, 'b')),
+ ]
+ )
+ ]
+ )
+
if __name__ == '__main__':
if '-v' in sys.argv:

Powered by Google App Engine
This is Rietveld 408576698