Skip to content

Commit

Permalink
add UT for special packs
Browse files Browse the repository at this point in the history
  • Loading branch information
israelpoli committed Apr 1, 2024
1 parent d2bde87 commit cfa25a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 21 additions & 0 deletions demisto_sdk/commands/validate/tests/IF_validators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
IsFieldTypeChangedValidator,
)
from demisto_sdk.commands.validate.validators.IF_validators.IF113_name_field_prefix import (
PACKS_IGNORE,
NameFieldPrefixValidator,
)
from demisto_sdk.commands.validate.validators.IF_validators.IF115_unsearchable_key import (
Expand Down Expand Up @@ -322,6 +323,26 @@ def test_NameFieldPrefixValidator_is_valid_with_item_prefix(
assert not NameFieldPrefixValidator().is_valid([content_item])


@pytest.mark.parametrize(
"special_pack",
PACKS_IGNORE
)
def test_NameFieldPrefixValidator_is_valid_with_special_packs(special_pack: str):
"""
Given:
- IncidentField content item whose pack name is one of the special packs
When:
- run is_valid method
Then:
- Ensure that no ValidationResult returned
"""
with ChangeCWD(REPO.path):
content_item = create_incident_field_object(
pack_info={"name": special_pack}
)
assert not NameFieldPrefixValidator().is_valid([content_item])


def test_IsValidContentFieldValidator_valid():
"""
Given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)

ContentTypes = IncidentField
PACKS_IGNORE = ["Common Types", "Core Alert Fields"]


class NameFieldPrefixValidator(BaseValidator[ContentTypes]):
Expand All @@ -34,7 +35,10 @@ def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResu
content_object=content_item,
)
for content_item in content_items
if (not name_include_allowed_prefix(content_item))
if (
content_item.pack_name not in PACKS_IGNORE
and not name_include_allowed_prefix(content_item)
)
]


Expand Down

0 comments on commit cfa25a1

Please sign in to comment.