From cfa25a11389ef34d0ce11d000d432297be78c6d7 Mon Sep 17 00:00:00 2001 From: israelpolishook Date: Mon, 1 Apr 2024 12:02:34 +0200 Subject: [PATCH] add UT for special packs --- .../validate/tests/IF_validators_test.py | 21 +++++++++++++++++++ .../IF_validators/IF113_name_field_prefix.py | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/demisto_sdk/commands/validate/tests/IF_validators_test.py b/demisto_sdk/commands/validate/tests/IF_validators_test.py index 37ef07c821..e10c135a3c 100644 --- a/demisto_sdk/commands/validate/tests/IF_validators_test.py +++ b/demisto_sdk/commands/validate/tests/IF_validators_test.py @@ -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 ( @@ -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: diff --git a/demisto_sdk/commands/validate/validators/IF_validators/IF113_name_field_prefix.py b/demisto_sdk/commands/validate/validators/IF_validators/IF113_name_field_prefix.py index 303d060058..a02f0b36d5 100644 --- a/demisto_sdk/commands/validate/validators/IF_validators/IF113_name_field_prefix.py +++ b/demisto_sdk/commands/validate/validators/IF_validators/IF113_name_field_prefix.py @@ -10,6 +10,7 @@ ) ContentTypes = IncidentField +PACKS_IGNORE = ["Common Types", "Core Alert Fields"] class NameFieldPrefixValidator(BaseValidator[ContentTypes]): @@ -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) + ) ]