diff options
Diffstat (limited to 'meta/lib/oeqa/core/tests/test_decorators.py')
-rwxr-xr-x | meta/lib/oeqa/core/tests/test_decorators.py | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py b/meta/lib/oeqa/core/tests/test_decorators.py index 499cd66ff3..b798bf7d33 100755 --- a/meta/lib/oeqa/core/tests/test_decorators.py +++ b/meta/lib/oeqa/core/tests/test_decorators.py | |||
@@ -14,35 +14,58 @@ setup_sys_path() | |||
14 | from oeqa.core.exception import OEQADependency | 14 | from oeqa.core.exception import OEQADependency |
15 | from oeqa.core.utils.test import getCaseMethod, getSuiteCasesNames, getSuiteCasesIDs | 15 | from oeqa.core.utils.test import getCaseMethod, getSuiteCasesNames, getSuiteCasesIDs |
16 | 16 | ||
17 | class TestFilterDecorator(TestBase): | 17 | class TestTagDecorator(TestBase): |
18 | 18 | def _runTest(self, modules, filterfn, expect): | |
19 | def _runFilterTest(self, modules, filters, expect, msg): | 19 | tc = self._testLoader(modules = modules, tags_filter = filterfn) |
20 | tc = self._testLoader(modules=modules, filters=filters) | 20 | test_loaded = set(getSuiteCasesIDs(tc.suites)) |
21 | test_loaded = set(getSuiteCasesNames(tc.suites)) | 21 | self.assertEqual(expect, test_loaded) |
22 | self.assertEqual(expect, test_loaded, msg=msg) | ||
23 | 22 | ||
24 | def test_oetag(self): | 23 | def test_oetag(self): |
25 | # Get all cases without filtering. | 24 | # get all cases without any filtering |
26 | filter_all = {} | 25 | self._runTest(['oetag'], None, { |
27 | test_all = {'testTagGood', 'testTagOther', 'testTagNone'} | 26 | 'oetag.TagTest.testTagGood', |
28 | msg_all = 'Failed to get all oetag cases without filtering.' | 27 | 'oetag.TagTest.testTagOther', |
29 | 28 | 'oetag.TagTest.testTagOtherMulti', | |
30 | # Get cases with 'goodTag'. | 29 | 'oetag.TagTest.testTagNone', |
31 | filter_good = {'oetag':'goodTag'} | 30 | 'oetag.TagClassTest.testTagOther', |
32 | test_good = {'testTagGood'} | 31 | 'oetag.TagClassTest.testTagOtherMulti', |
33 | msg_good = 'Failed to get just one test filtering with "goodTag" oetag.' | 32 | 'oetag.TagClassTest.testTagNone', |
34 | 33 | }) | |
35 | # Get cases with an invalid tag. | 34 | |
36 | filter_invalid = {'oetag':'invalidTag'} | 35 | # exclude any case with tags |
37 | test_invalid = set() | 36 | self._runTest(['oetag'], lambda tags: tags, { |
38 | msg_invalid = 'Failed to filter all test using an invalid oetag.' | 37 | 'oetag.TagTest.testTagNone', |
39 | 38 | }) | |
40 | tests = ((filter_all, test_all, msg_all), | 39 | |
41 | (filter_good, test_good, msg_good), | 40 | # exclude any case with otherTag |
42 | (filter_invalid, test_invalid, msg_invalid)) | 41 | self._runTest(['oetag'], lambda tags: "otherTag" in tags, { |
43 | 42 | 'oetag.TagTest.testTagGood', | |
44 | for test in tests: | 43 | 'oetag.TagTest.testTagNone', |
45 | self._runFilterTest(['oetag'], test[0], test[1], test[2]) | 44 | 'oetag.TagClassTest.testTagNone', |
45 | }) | ||
46 | |||
47 | # exclude any case with classTag | ||
48 | self._runTest(['oetag'], lambda tags: "classTag" in tags, { | ||
49 | 'oetag.TagTest.testTagGood', | ||
50 | 'oetag.TagTest.testTagOther', | ||
51 | 'oetag.TagTest.testTagOtherMulti', | ||
52 | 'oetag.TagTest.testTagNone', | ||
53 | }) | ||
54 | |||
55 | # include any case with classTag | ||
56 | self._runTest(['oetag'], lambda tags: "classTag" not in tags, { | ||
57 | 'oetag.TagClassTest.testTagOther', | ||
58 | 'oetag.TagClassTest.testTagOtherMulti', | ||
59 | 'oetag.TagClassTest.testTagNone', | ||
60 | }) | ||
61 | |||
62 | # include any case with classTag or no tags | ||
63 | self._runTest(['oetag'], lambda tags: tags and "classTag" not in tags, { | ||
64 | 'oetag.TagTest.testTagNone', | ||
65 | 'oetag.TagClassTest.testTagOther', | ||
66 | 'oetag.TagClassTest.testTagOtherMulti', | ||
67 | 'oetag.TagClassTest.testTagNone', | ||
68 | }) | ||
46 | 69 | ||
47 | class TestDependsDecorator(TestBase): | 70 | class TestDependsDecorator(TestBase): |
48 | modules = ['depends'] | 71 | modules = ['depends'] |