Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Added support to negated PICS #170

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions app/pics_applicable_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from typing import Dict
from typing import Dict, Tuple

from loguru import logger

from app.schemas.pics import PICS, PICSApplicableTestCases
from app.test_engine.models.test_declarations import TestCollectionDeclaration
from app.test_engine.models.test_declarations import (
TestCaseDeclaration,
TestCollectionDeclaration,
)
from app.test_engine.test_script_manager import test_script_manager


Expand Down Expand Up @@ -74,6 +77,27 @@ def __applicable_test_cases(
# Test cases without pics required are always applicable
applicable_tests.append(test_case.metadata["title"])
elif len(test_case.pics) > 0:
if test_case.pics.issubset(enabled_pics):
test_enabled_pics, test_disabled_pics = __retrieve_pics(
test_case
)

# Checking if the test case is applicable
if test_enabled_pics.issubset(
enabled_pics
) and test_disabled_pics.isdisjoint(enabled_pics):
applicable_tests.append(test_case.metadata["title"])
return applicable_tests


def __retrieve_pics(test_case: TestCaseDeclaration) -> Tuple[set, set]:
enabled_pics_list: set = set()
disabled_pics_list: set = set()
for pics in test_case.pics:
# The '!' char before PICS definition, is how test case flag a PICS as negative
if pics.startswith("!"):
# Ignore ! char while adding the pics into disabled_pics_list structure
disabled_pics_list.add(pics[1:])
else:
enabled_pics_list.add(pics)

return enabled_pics_list, disabled_pics_list
Loading