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

Side by Side Diff: third_party/cq_client/test/validate_config_test.py

Issue 1697053003: Roll cq_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Unit tests for tools/validate_config.py."""
6
7 import mock
8 import os
9 import unittest
10
11 from cq_client import cq_pb2
12 from cq_client import validate_config
13
14
15 TEST_DIR = os.path.dirname(os.path.abspath(__file__))
16
17
18 class TestValidateConfig(unittest.TestCase):
19 def test_is_valid_rietveld(self):
20 with open(os.path.join(TEST_DIR, 'cq_rietveld.cfg'), 'r') as test_config:
21 self.assertTrue(validate_config.IsValid(test_config.read()))
22
23 def test_is_valid_gerrit(self):
24 with open(os.path.join(TEST_DIR, 'cq_gerrit.cfg'), 'r') as test_config:
25 self.assertTrue(validate_config.IsValid(test_config.read()))
26
27 def test_one_codereview(self):
28 with open(os.path.join(TEST_DIR, 'cq_gerrit.cfg'), 'r') as gerrit_config:
29 data = gerrit_config.read()
30 data += '\n'.join([
31 'rietveld{',
32 'url: "https://blabla.com"',
33 '}'
34 ])
35 self.assertFalse(validate_config.IsValid(data))
36
37 def test_has_field(self):
38 config = cq_pb2.Config()
39
40 self.assertFalse(validate_config._HasField(config, 'version'))
41 config.version = 1
42 self.assertTrue(validate_config._HasField(config, 'version'))
43
44 self.assertFalse(validate_config._HasField(
45 config, 'rietveld.project_bases'))
46 config.rietveld.project_bases.append('foo://bar')
47 self.assertTrue(validate_config._HasField(
48 config, 'rietveld.project_bases'))
49
50 self.assertFalse(validate_config._HasField(
51 config, 'verifiers.try_job.buckets'))
52 self.assertFalse(validate_config._HasField(
53 config, 'verifiers.try_job.buckets.name'))
54
55 bucket = config.verifiers.try_job.buckets.add()
56 bucket.name = 'tryserver.chromium.linux'
57
58
59 self.assertTrue(validate_config._HasField(
60 config, 'verifiers.try_job.buckets'))
61 self.assertTrue(validate_config._HasField(
62 config, 'verifiers.try_job.buckets.name'))
63
64 config.verifiers.try_job.buckets.add()
65 self.assertFalse(validate_config._HasField(
66 config, 'verifiers.try_job.buckets.name'))
OLDNEW
« no previous file with comments | « third_party/cq_client/test/cq_rietveld.cfg ('k') | third_party/cq_client/testdata/cq_gerrit.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698