From f53974394b38ed2aaaa9c29542920a10b4b398c9 Mon Sep 17 00:00:00 2001 From: edik24 Date: Mon, 9 Sep 2024 13:24:22 +0300 Subject: [PATCH 01/13] fixing validations --- .../content_graph/parsers/related_files.py | 10 +++-- .../RM116_missing_playbook_image.py | 38 +++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py diff --git a/demisto_sdk/commands/content_graph/parsers/related_files.py b/demisto_sdk/commands/content_graph/parsers/related_files.py index 323294f4216..8c89d5e0611 100644 --- a/demisto_sdk/commands/content_graph/parsers/related_files.py +++ b/demisto_sdk/commands/content_graph/parsers/related_files.py @@ -278,17 +278,19 @@ class ImageRelatedFile(PNGFiles): file_type = RelatedFileType.IMAGE def get_optional_paths(self) -> List[Path]: - return [ + optional_paths_list = [ self.main_file_path.parents[1] / "doc_files" / str(self.main_file_path.parts[-1]) .replace(".yml", ".png") .replace("playbook-", ""), - Path(str(self.main_file_path).replace(".yml", ".png")), self.main_file_path.parent / f"{self.main_file_path.parts[-2]}_image.png", - Path(str(self.main_file_path).replace(".json", "_image.png")), ] - + if self.main_file_path.suffix == ".json": + optional_paths_list.append(Path(str(self.main_file_path).replace(".json", "_image.png"))) + else: + optional_paths_list.append(Path(str(self.main_file_path).replace(".yml", ".png")),) + return optional_paths_list class AuthorImageRelatedFile(PNGFiles): file_type = RelatedFileType.AUTHOR_IMAGE diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py new file mode 100644 index 00000000000..48b77a86ab2 --- /dev/null +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -0,0 +1,38 @@ + +from __future__ import annotations + +from typing import Iterable, List + +from demisto_sdk.commands.content_graph.objects.playbook import Playbook +from demisto_sdk.commands.validate.validators.base_validator import ( + BaseValidator, + ValidationResult, +) + +ContentTypes = Playbook + + +class MissingPlaybookImageValidator(BaseValidator[ContentTypes]): + error_code = "RM116" + description = "Verifies that a playbook image exists in the doc_files folder" + rationale = "It is recommended to have an image for every playbook for better understanding and documentation" + error_message = "No playbook image found, please add playbook image" + related_field = "" + is_auto_fixable = False + + + def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: + return [ + ValidationResult( + validator=self, + message=self.error_message, + content_object=content_item, + ) + for content_item in content_items + if ( + not content_item.image.exist or 'doc_files' not in str(content_item.image.file_path) + ) + ] + + + From 99c3b7901a47b8ab2cd8c921ef87a498ef25cf76 Mon Sep 17 00:00:00 2001 From: edik24 Date: Tue, 10 Sep 2024 14:17:08 +0300 Subject: [PATCH 02/13] Add validation to validation_config --- demisto_sdk/commands/validate/sdk_validation_config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/demisto_sdk/commands/validate/sdk_validation_config.toml b/demisto_sdk/commands/validate/sdk_validation_config.toml index 8797b08d489..ae251452ff3 100644 --- a/demisto_sdk/commands/validate/sdk_validation_config.toml +++ b/demisto_sdk/commands/validate/sdk_validation_config.toml @@ -411,6 +411,7 @@ select = [ "RM109", "RM113", "RM114", + "RM116", "CL100", "PR101", "CR102", From 4f5d318c474e401fad03d0eea5d80013aee1ca1e Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 11 Sep 2024 13:04:35 +0300 Subject: [PATCH 03/13] Add validation to validation_config --- .changelog/4538.yml | 4 +++ .../validate/tests/RM_validators_test.py | 33 +++++++++++++++++++ .../RM116_missing_playbook_image.py | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .changelog/4538.yml diff --git a/.changelog/4538.yml b/.changelog/4538.yml new file mode 100644 index 00000000000..b9414885f44 --- /dev/null +++ b/.changelog/4538.yml @@ -0,0 +1,4 @@ +changes: +- description: Added RM116 that will validate if the playbook has an image located in doc_files folder + type: feature +pr_number: 4538 diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 6d7b4972daf..472dc39baf6 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -1,6 +1,7 @@ from pathlib import Path import pytest +from markdown_it.rules_inline import image from demisto_sdk.commands.validate.tests.test_tools import ( REPO, @@ -39,6 +40,9 @@ from demisto_sdk.commands.validate.validators.RM_validators.RM114_is_image_exists_in_readme import ( IsImageExistsInReadmeValidator, ) +from demisto_sdk.commands.validate.validators.RM_validators.RM116_missing_playbook_image import ( + MissingPlaybookImageValidator, +) from TestSuite.repo import ChangeCWD @@ -636,3 +640,32 @@ def test_VerifyTemplateInReadmeValidator_invalid_case(repo): ), ] assert not IsTemplateInReadmeValidator().obtain_invalid_content_items(content_items) + + +def test_missing_playbook_image_validator_no_image(): + content_items = [ + create_playbook_object(), + ] + expected_msg = "No playbook image found, please add playbook image" + result = MissingPlaybookImageValidator().obtain_invalid_content_items( + content_items + ) + assert len(result) == 1 + + if result: + assert result[0].message == expected_msg + + +def test_missing_playbook_image_validator_image_exists(): + content_items = [ + create_playbook_object(), + ] + content_items[0].image.exist = True + expected_msg = "No playbook image found, please add playbook image" + result = MissingPlaybookImageValidator().obtain_invalid_content_items( + content_items + ) + assert len(result) == 0 + + if result: + assert result[0].message == expected_msg diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index 48b77a86ab2..40ef3403ef1 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -30,7 +30,7 @@ def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> ) for content_item in content_items if ( - not content_item.image.exist or 'doc_files' not in str(content_item.image.file_path) + not content_item.image.exist or 'doc_files' in str(content_item.image.file_path) ) ] From 75bdec853c47f739276116d3619651ad05731281 Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 11 Sep 2024 13:05:34 +0300 Subject: [PATCH 04/13] Add validation to validation_config --- .../validators/RM_validators/RM116_missing_playbook_image.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index 40ef3403ef1..10942c18a1f 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -33,6 +33,3 @@ def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> not content_item.image.exist or 'doc_files' in str(content_item.image.file_path) ) ] - - - From 16cb904dd2679025e4a50741e5715a1cbff9a8e4 Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 11 Sep 2024 15:18:48 +0300 Subject: [PATCH 05/13] Add validation to validation_config --- .../commands/content_graph/parsers/related_files.py | 9 +++++++-- .../commands/validate/tests/RM_validators_test.py | 9 ++------- .../RM_validators/RM116_missing_playbook_image.py | 13 +++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/demisto_sdk/commands/content_graph/parsers/related_files.py b/demisto_sdk/commands/content_graph/parsers/related_files.py index 8c89d5e0611..3f8e6103f3b 100644 --- a/demisto_sdk/commands/content_graph/parsers/related_files.py +++ b/demisto_sdk/commands/content_graph/parsers/related_files.py @@ -287,11 +287,16 @@ def get_optional_paths(self) -> List[Path]: self.main_file_path.parent / f"{self.main_file_path.parts[-2]}_image.png", ] if self.main_file_path.suffix == ".json": - optional_paths_list.append(Path(str(self.main_file_path).replace(".json", "_image.png"))) + optional_paths_list.append( + Path(str(self.main_file_path).replace(".json", "_image.png")) + ) else: - optional_paths_list.append(Path(str(self.main_file_path).replace(".yml", ".png")),) + optional_paths_list.append( + Path(str(self.main_file_path).replace(".yml", ".png")), + ) return optional_paths_list + class AuthorImageRelatedFile(PNGFiles): file_type = RelatedFileType.AUTHOR_IMAGE diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 472dc39baf6..7f12f515ec6 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -1,7 +1,6 @@ from pathlib import Path import pytest -from markdown_it.rules_inline import image from demisto_sdk.commands.validate.tests.test_tools import ( REPO, @@ -647,9 +646,7 @@ def test_missing_playbook_image_validator_no_image(): create_playbook_object(), ] expected_msg = "No playbook image found, please add playbook image" - result = MissingPlaybookImageValidator().obtain_invalid_content_items( - content_items - ) + result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) assert len(result) == 1 if result: @@ -662,9 +659,7 @@ def test_missing_playbook_image_validator_image_exists(): ] content_items[0].image.exist = True expected_msg = "No playbook image found, please add playbook image" - result = MissingPlaybookImageValidator().obtain_invalid_content_items( - content_items - ) + result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) assert len(result) == 0 if result: diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index 10942c18a1f..ac53175ddd6 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -1,12 +1,11 @@ - from __future__ import annotations from typing import Iterable, List from demisto_sdk.commands.content_graph.objects.playbook import Playbook from demisto_sdk.commands.validate.validators.base_validator import ( - BaseValidator, - ValidationResult, + BaseValidator, + ValidationResult, ) ContentTypes = Playbook @@ -20,8 +19,9 @@ class MissingPlaybookImageValidator(BaseValidator[ContentTypes]): related_field = "" is_auto_fixable = False - - def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: + def obtain_invalid_content_items( + self, content_items: Iterable[ContentTypes] + ) -> List[ValidationResult]: return [ ValidationResult( validator=self, @@ -30,6 +30,7 @@ def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> ) for content_item in content_items if ( - not content_item.image.exist or 'doc_files' in str(content_item.image.file_path) + not content_item.image.exist + or "doc_files" in str(content_item.image.file_path) ) ] From 4b2b52eb9ff6f3811df2b98715349bbce3274ba8 Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 11 Sep 2024 16:29:38 +0300 Subject: [PATCH 06/13] Add validation to validation_config --- .changelog/4538.yml | 2 +- .../validate/sdk_validation_config.toml | 1 + .../validate/tests/RM_validators_test.py | 52 ++++++++++++++++--- .../RM116_missing_playbook_image.py | 8 +-- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.changelog/4538.yml b/.changelog/4538.yml index b9414885f44..8b0a7252c7f 100644 --- a/.changelog/4538.yml +++ b/.changelog/4538.yml @@ -1,4 +1,4 @@ changes: -- description: Added RM116 that will validate if the playbook has an image located in doc_files folder +- description: Added RM116 validation to the new validate flow. The validation ensure that every playbook has an image and that the image is located under doc_files folder. type: feature pr_number: 4538 diff --git a/demisto_sdk/commands/validate/sdk_validation_config.toml b/demisto_sdk/commands/validate/sdk_validation_config.toml index 6b5fddf1545..a9b491e1ec0 100644 --- a/demisto_sdk/commands/validate/sdk_validation_config.toml +++ b/demisto_sdk/commands/validate/sdk_validation_config.toml @@ -61,6 +61,7 @@ ignorable_errors = [ "RM110", "RM112", "RM113", + "RM116", "RP102", "RP104", "SC100", diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 2ee204dbfc6..a3fb8797ec4 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -1,3 +1,5 @@ +from pathlib import PosixPath + import pytest from demisto_sdk.commands.common.tools import find_pack_folder @@ -863,25 +865,59 @@ def test_get_command_context_path_from_readme_file_multiple_commands(): def test_missing_playbook_image_validator_no_image(): + """ + Given + content_items. + - Playbook without an image + When + - Calling the MissingPlaybookImageValidator obtain_invalid_content_items function. + + Then + - Make sure that the validator returns an error + """ content_items = [ create_playbook_object(), ] - expected_msg = "No playbook image found, please add playbook image" result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) assert len(result) == 1 - if result: - assert result[0].message == expected_msg +def test_missing_playbook_image_validator_image_exists_wrong_path(): + """ + Given + content_items. + - Playbook with an image, but wrong path (the path doesn't include doc_files folder) + When + - Calling the MissingPlaybookImageValidator obtain_invalid_content_items function. -def test_missing_playbook_image_validator_image_exists(): + Then + - Make sure that the validator returns an error + """ content_items = [ create_playbook_object(), ] content_items[0].image.exist = True - expected_msg = "No playbook image found, please add playbook image" result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) - assert len(result) == 0 + assert len(result) == 1 - if result: - assert result[0].message == expected_msg + +def test_missing_playbook_image_validator_image_exists_with_path(): + """ + Given + content_items. + - Playbook with an image and correct path + When + - Calling the MissingPlaybookImageValidator obtain_invalid_content_items function. + + Then + - Make sure that the validator returns an empty list + """ + content_items = [ + create_playbook_object(), + ] + content_items[0].image.exist = True + content_items[0].image.file_path = PosixPath( + "/var/folders/sd/bk6skd0j1xz7l1g8d4dhfn7c0000gp/T/tmpjmydes4n/Packs/doc_files/Playbooks/playbook-0.png" + ) + result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) + assert len(result) == 0 diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index ac53175ddd6..2e247ed5b79 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -14,9 +14,9 @@ class MissingPlaybookImageValidator(BaseValidator[ContentTypes]): error_code = "RM116" description = "Verifies that a playbook image exists in the doc_files folder" - rationale = "It is recommended to have an image for every playbook for better understanding and documentation" - error_message = "No playbook image found, please add playbook image" - related_field = "" + rationale = "It is recommended to have an image for every playbook for better understanding and documentation." + error_message = "Couldn't find an image for the playbook under doc_files, please make sure the playbook has an image and that it is located under the pack's doc_files folder." + related_field = "image" is_auto_fixable = False def obtain_invalid_content_items( @@ -31,6 +31,6 @@ def obtain_invalid_content_items( for content_item in content_items if ( not content_item.image.exist - or "doc_files" in str(content_item.image.file_path) + or "doc_files" not in str(content_item.image.file_path) ) ] From f580bd11ffdaa7d6a3b0b30363a0fe902c0d9aa9 Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 25 Sep 2024 11:51:03 +0300 Subject: [PATCH 07/13] fixing validations --- .../validators/RM_validators/RM116_missing_playbook_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index 48b77a86ab2..f044bb63789 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -15,7 +15,7 @@ class MissingPlaybookImageValidator(BaseValidator[ContentTypes]): error_code = "RM116" description = "Verifies that a playbook image exists in the doc_files folder" - rationale = "It is recommended to have an image for every playbook for better understanding and documentation" + rationale = "It is recommended to have an image for every playbook for a better understanding and documentation" error_message = "No playbook image found, please add playbook image" related_field = "" is_auto_fixable = False From 038bc1046a6ac0c4fb253c6bbb4c86b1115bb7ef Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 25 Sep 2024 11:54:07 +0300 Subject: [PATCH 08/13] fixing validations --- demisto_sdk/commands/validate/tests/RM_validators_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 8d755aa8dba..9c9d0a437f8 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -910,7 +910,7 @@ def test_IsCommandsInReadmeValidator_valid(): [content_item] ) - <<<<<< rm116 + def test_missing_playbook_image_validator_no_image(): """ Given From 889ab5b83c6e8ccff3efe5d0f1d9cd38628bab52 Mon Sep 17 00:00:00 2001 From: edik24 Date: Wed, 25 Sep 2024 13:18:57 +0300 Subject: [PATCH 09/13] fixing validations --- .../validate/tests/RM_validators_test.py | 4 +++- .../RM116_missing_playbook_image.py | 16 +++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 9c9d0a437f8..21af6790f98 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -1,6 +1,8 @@ +from pathlib import PosixPath + import more_itertools import pytest -from pathlib import PosixPath + from demisto_sdk.commands.common.tools import find_pack_folder from demisto_sdk.commands.validate.tests.test_tools import ( REPO, diff --git a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py index 48b77a86ab2..a501ae1ec24 100644 --- a/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py +++ b/demisto_sdk/commands/validate/validators/RM_validators/RM116_missing_playbook_image.py @@ -1,12 +1,11 @@ - from __future__ import annotations from typing import Iterable, List from demisto_sdk.commands.content_graph.objects.playbook import Playbook from demisto_sdk.commands.validate.validators.base_validator import ( - BaseValidator, - ValidationResult, + BaseValidator, + ValidationResult, ) ContentTypes = Playbook @@ -20,8 +19,9 @@ class MissingPlaybookImageValidator(BaseValidator[ContentTypes]): related_field = "" is_auto_fixable = False - - def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: + def obtain_invalid_content_items( + self, content_items: Iterable[ContentTypes] + ) -> List[ValidationResult]: return [ ValidationResult( validator=self, @@ -30,9 +30,7 @@ def obtain_invalid_content_items(self, content_items: Iterable[ContentTypes]) -> ) for content_item in content_items if ( - not content_item.image.exist or 'doc_files' not in str(content_item.image.file_path) + not content_item.image.exist + or "doc_files" not in str(content_item.image.file_path) ) ] - - - From 9529f4f78add4feb932c56fee29fcdada4bddcda Mon Sep 17 00:00:00 2001 From: YuvHayun Date: Sun, 13 Oct 2024 16:37:25 +0300 Subject: [PATCH 10/13] document the vaious image paths --- .../content_graph/parsers/related_files.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/demisto_sdk/commands/content_graph/parsers/related_files.py b/demisto_sdk/commands/content_graph/parsers/related_files.py index 3f8e6103f3b..90f7b13dd90 100644 --- a/demisto_sdk/commands/content_graph/parsers/related_files.py +++ b/demisto_sdk/commands/content_graph/parsers/related_files.py @@ -278,19 +278,25 @@ class ImageRelatedFile(PNGFiles): file_type = RelatedFileType.IMAGE def get_optional_paths(self) -> List[Path]: + """ + Generate a list of optional paths for the content item's image. + The right path will be found later. + Returns: + List[Path]: the list of optional paths. + """ optional_paths_list = [ self.main_file_path.parents[1] / "doc_files" / str(self.main_file_path.parts[-1]) .replace(".yml", ".png") - .replace("playbook-", ""), - self.main_file_path.parent / f"{self.main_file_path.parts[-2]}_image.png", + .replace("playbook-", ""), # In case the playbook's image is located under doc_files with the same name as the playbook. + self.main_file_path.parent / f"{self.main_file_path.parts[-2]}_image.png", # In case of integration image where the image is located in the integration folder with the same name as the integration. ] - if self.main_file_path.suffix == ".json": + if self.main_file_path.suffix == ".json": # when editing .yml files, we don't want to end up with the yml file as part of the optional paths. optional_paths_list.append( Path(str(self.main_file_path).replace(".json", "_image.png")) ) - else: + else: # when editing .json files, we don't want to end up with the json file as part of the optional paths. optional_paths_list.append( Path(str(self.main_file_path).replace(".yml", ".png")), ) From c950a35e03caad5d0f830fab485c0ff670506738 Mon Sep 17 00:00:00 2001 From: edik24 Date: Tue, 15 Oct 2024 11:49:34 +0300 Subject: [PATCH 11/13] fixing validations --- .../commands/content_graph/parsers/related_files.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/demisto_sdk/commands/content_graph/parsers/related_files.py b/demisto_sdk/commands/content_graph/parsers/related_files.py index 90f7b13dd90..47f7ed102f9 100644 --- a/demisto_sdk/commands/content_graph/parsers/related_files.py +++ b/demisto_sdk/commands/content_graph/parsers/related_files.py @@ -289,14 +289,19 @@ def get_optional_paths(self) -> List[Path]: / "doc_files" / str(self.main_file_path.parts[-1]) .replace(".yml", ".png") - .replace("playbook-", ""), # In case the playbook's image is located under doc_files with the same name as the playbook. - self.main_file_path.parent / f"{self.main_file_path.parts[-2]}_image.png", # In case of integration image where the image is located in the integration folder with the same name as the integration. + .replace( + "playbook-", "" + ), # In case the playbook's image is located under doc_files folder with the same name as the playbook. + self.main_file_path.parent + / f"{self.main_file_path.parts[-2]}_image.png", # In case of integration image where the image is located in the integration folder with the same name as the integration. ] - if self.main_file_path.suffix == ".json": # when editing .yml files, we don't want to end up with the yml file as part of the optional paths. + if ( + self.main_file_path.suffix == ".json" + ): # when editing .yml files, we don't want to end up with the yml file as part of the optional paths. optional_paths_list.append( Path(str(self.main_file_path).replace(".json", "_image.png")) ) - else: # when editing .json files, we don't want to end up with the json file as part of the optional paths. + else: # when editing .json files, we don't want to end up with the json file as part of the optional paths. optional_paths_list.append( Path(str(self.main_file_path).replace(".yml", ".png")), ) From 7ac21fe059e783399114b7cfafaaad1d1117a761 Mon Sep 17 00:00:00 2001 From: edik24 Date: Tue, 15 Oct 2024 14:11:07 +0300 Subject: [PATCH 12/13] fixing validations --- demisto_sdk/commands/validate/sdk_validation_config.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/demisto_sdk/commands/validate/sdk_validation_config.toml b/demisto_sdk/commands/validate/sdk_validation_config.toml index e9801824848..364c6df993a 100644 --- a/demisto_sdk/commands/validate/sdk_validation_config.toml +++ b/demisto_sdk/commands/validate/sdk_validation_config.toml @@ -202,7 +202,6 @@ select = [ "RM113", "RM114", "RM115", - "RM116", "CL100", "PR101", "CR102", From 760f2c11ffd593d3d3805fab1fadbffa34aba1bf Mon Sep 17 00:00:00 2001 From: edik24 Date: Tue, 15 Oct 2024 14:21:26 +0300 Subject: [PATCH 13/13] fixing validations --- demisto_sdk/commands/validate/tests/RM_validators_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demisto_sdk/commands/validate/tests/RM_validators_test.py b/demisto_sdk/commands/validate/tests/RM_validators_test.py index 57c1c9e93fe..e5e7a8a3d0e 100644 --- a/demisto_sdk/commands/validate/tests/RM_validators_test.py +++ b/demisto_sdk/commands/validate/tests/RM_validators_test.py @@ -52,11 +52,12 @@ from demisto_sdk.commands.validate.validators.RM_validators.RM114_is_image_exists_in_readme import ( IsImageExistsInReadmeValidator, ) -from demisto_sdk.commands.validate.validators.RM_validators.RM116_missing_playbook_image import ( - MissingPlaybookImageValidator, from demisto_sdk.commands.validate.validators.RM_validators.RM115_no_default_section_left import ( NoDefaultSectionsLeftReadmeValidator, ) +from demisto_sdk.commands.validate.validators.RM_validators.RM116_missing_playbook_image import ( + MissingPlaybookImageValidator, +) from demisto_sdk.commands.validate.validators.RM_validators.RM116_readme_not_to_short import ( NotToShortReadmeValidator, ) @@ -980,7 +981,7 @@ def test_missing_playbook_image_validator_image_exists_with_path(): result = MissingPlaybookImageValidator().obtain_invalid_content_items(content_items) assert len(result) == 0 - + @pytest.mark.parametrize( "file_input, missing_section", [ @@ -1144,4 +1145,3 @@ def test_invalid_short_file(): not_to_short_readme_validator.obtain_invalid_content_items([test_pack]) ) assert result[0].message == short_readme_error -