|
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | 15 | # |
16 | | -from typing import Dict |
| 16 | +from typing import Dict, Tuple |
17 | 17 |
|
18 | 18 | from loguru import logger |
19 | 19 |
|
20 | 20 | from app.schemas.pics import PICS, PICSApplicableTestCases |
21 | | -from app.test_engine.models.test_declarations import TestCollectionDeclaration |
| 21 | +from app.test_engine.models.test_declarations import ( |
| 22 | + TestCaseDeclaration, |
| 23 | + TestCollectionDeclaration, |
| 24 | +) |
22 | 25 | from app.test_engine.test_script_manager import test_script_manager |
23 | 26 |
|
24 | 27 |
|
@@ -74,6 +77,27 @@ def __applicable_test_cases( |
74 | 77 | # Test cases without pics required are always applicable |
75 | 78 | applicable_tests.append(test_case.metadata["title"]) |
76 | 79 | elif len(test_case.pics) > 0: |
77 | | - if test_case.pics.issubset(enabled_pics): |
| 80 | + test_enabled_pics, test_disabled_pics = __retrieve_pics( |
| 81 | + test_case |
| 82 | + ) |
| 83 | + |
| 84 | + # Checking if the test case is applicable |
| 85 | + if test_enabled_pics.issubset( |
| 86 | + enabled_pics |
| 87 | + ) and test_disabled_pics.isdisjoint(enabled_pics): |
78 | 88 | applicable_tests.append(test_case.metadata["title"]) |
79 | 89 | return applicable_tests |
| 90 | + |
| 91 | + |
| 92 | +def __retrieve_pics(test_case: TestCaseDeclaration) -> Tuple[set, set]: |
| 93 | + enabled_pics_list: set = set() |
| 94 | + disabled_pics_list: set = set() |
| 95 | + for pics in test_case.pics: |
| 96 | + # The '!' char before PICS definition, is how test case flag a PICS as negative |
| 97 | + if pics.startswith("!"): |
| 98 | + # Ignore ! char while adding the pics into disabled_pics_list structure |
| 99 | + disabled_pics_list.add(pics[1:]) |
| 100 | + else: |
| 101 | + enabled_pics_list.add(pics) |
| 102 | + |
| 103 | + return enabled_pics_list, disabled_pics_list |
0 commit comments