Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rquidute committed Dec 4, 2024
1 parent c0ec582 commit 9ab50b1
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions app/pics_applicable_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 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

Expand Down Expand Up @@ -77,21 +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:
# Consider only enabled pics for test cases
test_enabled_pics = __retrieve_enabled_pics(test_case)

# test_case
if test_enabled_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_enabled_pics(test_case: TestCaseDeclaration) -> set:
pics_list: set = set()
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
# For applicable test cases, we should only consider enabled PICS
if not pics.startswith("!"):
pics_list.add(pics)
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 pics_list
return enabled_pics_list, disabled_pics_list

0 comments on commit 9ab50b1

Please sign in to comment.