root / test / qa.qa_config_unittest.py @ a0c3e726
History | View | Annotate | Download (3.2 kB)
1 |
#!/usr/bin/python
|
---|---|
2 |
#
|
3 |
|
4 |
# Copyright (C) 2012 Google Inc.
|
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU General Public License as published by
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
9 |
# (at your option) any later version.
|
10 |
#
|
11 |
# This program is distributed in the hope that it will be useful, but
|
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
# General Public License for more details.
|
15 |
#
|
16 |
# You should have received a copy of the GNU General Public License
|
17 |
# along with this program; if not, write to the Free Software
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
# 02110-1301, USA.
|
20 |
|
21 |
|
22 |
"""Script for testing qa.qa_config"""
|
23 |
|
24 |
import unittest |
25 |
|
26 |
from qa import qa_config |
27 |
|
28 |
import testutils |
29 |
|
30 |
|
31 |
class TestTestEnabled(unittest.TestCase): |
32 |
def testSimple(self): |
33 |
for name in ["test", ["foobar"], ["a", "b"]]: |
34 |
self.assertTrue(qa_config.TestEnabled(name, _cfg={}))
|
35 |
|
36 |
for default in [False, True]: |
37 |
self.assertFalse(qa_config.TestEnabled("foo", _cfg={ |
38 |
"tests": {
|
39 |
"default": default,
|
40 |
"foo": False, |
41 |
}, |
42 |
})) |
43 |
|
44 |
self.assertTrue(qa_config.TestEnabled("bar", _cfg={ |
45 |
"tests": {
|
46 |
"default": default,
|
47 |
"bar": True, |
48 |
}, |
49 |
})) |
50 |
|
51 |
def testEitherWithDefault(self): |
52 |
names = qa_config.Either("one")
|
53 |
|
54 |
self.assertTrue(qa_config.TestEnabled(names, _cfg={
|
55 |
"tests": {
|
56 |
"default": True, |
57 |
}, |
58 |
})) |
59 |
|
60 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
61 |
"tests": {
|
62 |
"default": False, |
63 |
}, |
64 |
})) |
65 |
|
66 |
def testEither(self): |
67 |
names = [qa_config.Either(["one", "two"]), |
68 |
qa_config.Either("foo"),
|
69 |
"hello",
|
70 |
["bar", "baz"]] |
71 |
|
72 |
self.assertTrue(qa_config.TestEnabled(names, _cfg={
|
73 |
"tests": {
|
74 |
"default": True, |
75 |
}, |
76 |
})) |
77 |
|
78 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
79 |
"tests": {
|
80 |
"default": False, |
81 |
}, |
82 |
})) |
83 |
|
84 |
for name in ["foo", "bar", "baz", "hello"]: |
85 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
86 |
"tests": {
|
87 |
"default": True, |
88 |
name: False,
|
89 |
}, |
90 |
})) |
91 |
|
92 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
93 |
"tests": {
|
94 |
"default": True, |
95 |
"one": False, |
96 |
"two": False, |
97 |
}, |
98 |
})) |
99 |
|
100 |
self.assertTrue(qa_config.TestEnabled(names, _cfg={
|
101 |
"tests": {
|
102 |
"default": True, |
103 |
"one": False, |
104 |
"two": True, |
105 |
}, |
106 |
})) |
107 |
|
108 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
109 |
"tests": {
|
110 |
"default": True, |
111 |
"one": True, |
112 |
"two": True, |
113 |
"foo": False, |
114 |
}, |
115 |
})) |
116 |
|
117 |
def testEitherNestedWithAnd(self): |
118 |
names = qa_config.Either([["one", "two"], "foo"]) |
119 |
|
120 |
self.assertTrue(qa_config.TestEnabled(names, _cfg={
|
121 |
"tests": {
|
122 |
"default": True, |
123 |
}, |
124 |
})) |
125 |
|
126 |
for name in ["one", "two"]: |
127 |
self.assertFalse(qa_config.TestEnabled(names, _cfg={
|
128 |
"tests": {
|
129 |
"default": True, |
130 |
"foo": False, |
131 |
name: False,
|
132 |
}, |
133 |
})) |
134 |
|
135 |
|
136 |
if __name__ == "__main__": |
137 |
testutils.GanetiTestProgram() |