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

Unified Diff: appengine/cr-buildbucket/test/protoutil_test.py

Issue 2213723002: swarmbucket: allow overriding config (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@sb-cfg-refactoring
Patch Set: security warning 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
« no previous file with comments | « appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cr-buildbucket/test/protoutil_test.py
diff --git a/appengine/cr-buildbucket/test/protoutil_test.py b/appengine/cr-buildbucket/test/protoutil_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..1c258d536c52f8315e05892dabc0e4ba6da41253
--- /dev/null
+++ b/appengine/cr-buildbucket/test/protoutil_test.py
@@ -0,0 +1,40 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from google.appengine.ext import ndb
+from testing_utils import testing
+
+from proto import project_config_pb2
+import protoutil
+
+
+class JsonpbTest(testing.AppengineTestCase):
+ def test_unmarshal_dict(self):
+ msg = project_config_pb2.Swarming()
+ data = {
+ 'common_dimensions': ['a:a', 'b:b'],
+ 'common_execution_timeout_secs': 600,
+ 'common_recipe': {
+ 'name': 'trybot',
+ },
+ 'builders': [
+ {'name': 'debug'},
+ {'name': 'release'},
+ ],
+ }
+ protoutil.merge_dict(data, msg)
+ self.assertEqual(msg.common_dimensions, ['a:a', 'b:b'])
+ self.assertEqual(msg.common_execution_timeout_secs, 600)
+ self.assertEqual(len(msg.builders), 2)
+ self.assertEqual(msg.builders[0].name, 'debug')
+
+ msg = project_config_pb2.Swarming()
+ with self.assertRaises(TypeError):
+ protoutil.merge_dict([], msg)
+
+ with self.assertRaises(TypeError):
+ protoutil.merge_dict({'no_such_field': 0}, msg)
+
+ with self.assertRaises(TypeError):
+ protoutil.merge_dict({'common_dimensions': 0}, msg)
« no previous file with comments | « appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698