Skip to content

Commit 60c4d58

Browse files
authored
[FIX] Added support to negated PICS (#170)
* Added support to negated PICS * Fixed flake * Code review. No consider negatives PICS * Update app/pics_applicable_test_cases.py * Code review
1 parent 913752e commit 60c4d58

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

app/pics_applicable_test_cases.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
from typing import Dict
16+
from typing import Dict, Tuple
1717

1818
from loguru import logger
1919

2020
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+
)
2225
from app.test_engine.test_script_manager import test_script_manager
2326

2427

@@ -74,6 +77,27 @@ def __applicable_test_cases(
7477
# Test cases without pics required are always applicable
7578
applicable_tests.append(test_case.metadata["title"])
7679
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):
7888
applicable_tests.append(test_case.metadata["title"])
7989
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

Comments
 (0)