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

Unified Diff: third_party/cq_client/test/validate_config_test.py

Issue 1200863002: Update cq_client and add validate command to commit_queue binary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Addressed comments Created 5 years, 6 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 | « third_party/cq_client/test/cq_example.cfg ('k') | third_party/cq_client/validate_config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/cq_client/test/validate_config_test.py
diff --git a/third_party/cq_client/test/validate_config_test.py b/third_party/cq_client/test/validate_config_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..d7c09714a05be2bbe4035d418107b2be6de56118
--- /dev/null
+++ b/third_party/cq_client/test/validate_config_test.py
@@ -0,0 +1,52 @@
+# 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.
+
+"""Unit tests for tools/validate_config.py."""
+
+import mock
+import os
+import unittest
+
+from cq_client import cq_pb2
+from cq_client import validate_config
+
+
+TEST_DIR = os.path.dirname(os.path.abspath(__file__))
+
+
+class TestValidateConfig(unittest.TestCase):
+ def test_is_valid(self):
+ with open(os.path.join(TEST_DIR, 'cq_example.cfg'), 'r') as test_config:
+ self.assertTrue(validate_config.IsValid(test_config.read()))
+
+ def test_has_field(self):
+ config = cq_pb2.Config()
+
+ self.assertFalse(validate_config._HasField(config, 'version'))
+ config.version = 1
+ self.assertTrue(validate_config._HasField(config, 'version'))
+
+ self.assertFalse(validate_config._HasField(
+ config, 'rietveld.project_bases'))
+ config.rietveld.project_bases.append('foo://bar')
+ self.assertTrue(validate_config._HasField(
+ config, 'rietveld.project_bases'))
+
+ self.assertFalse(validate_config._HasField(
+ config, 'verifiers.try_job.buckets'))
+ self.assertFalse(validate_config._HasField(
+ config, 'verifiers.try_job.buckets.name'))
+
+ bucket = config.verifiers.try_job.buckets.add()
+ bucket.name = 'tryserver.chromium.linux'
+
+
+ self.assertTrue(validate_config._HasField(
+ config, 'verifiers.try_job.buckets'))
+ self.assertTrue(validate_config._HasField(
+ config, 'verifiers.try_job.buckets.name'))
+
+ config.verifiers.try_job.buckets.add()
+ self.assertFalse(validate_config._HasField(
+ config, 'verifiers.try_job.buckets.name'))
« no previous file with comments | « third_party/cq_client/test/cq_example.cfg ('k') | third_party/cq_client/validate_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698