def are_release_notes_complete(self): is_valid = True modified_added_files = itertools.chain.from_iterable((self.added_files or [], self.modified_files or [])) if modified_added_files: for file in modified_added_files: # renamed files will appear in the modified list as a tuple: (old path, new path) if isinstance(file, tuple): file = file[1] if find_type(file) in self.file_types_that_should_not_appear_in_rn: continue elif self.pack_name + '/' in file: # Refer image and description file paths to the corresponding yml files file = UpdateRN.check_for_release_notes_valid_file_path(file) update_rn_util = UpdateRN(pack_path=self.release_notes_file_path, modified_files_in_pack=set(), update_type=None, added_files=set(), pack=self.pack_name) file_name, file_type = update_rn_util.identify_changed_file_type(file) if file_name and file_type: if (RN_HEADER_BY_FILE_TYPE[file_type] not in self.latest_release_notes) or \ (file_name not in self.latest_release_notes): entity_name = update_rn_util.get_display_name(file) error_message, error_code = Errors.missing_release_notes_entry(file_type, self.pack_name, entity_name) if self.handle_error(error_message, error_code, self.release_notes_file_path): is_valid = False return is_valid
def test_check_for_release_notes_valid_file_path(self): """ Given: case 1: a description file case 2: an image file case 3: a non-image or description file When: running check_for_release_notes_valid_file_path method Then: case 1 & 2: change the file path to the corresponding yml file. case 3: file path remains unchnaged """ from demisto_sdk.commands.update_release_notes.update_rn import UpdateRN image_file_path = "Packs/DNSDB/Integrations/DNSDB_v2/DNSDB_v2_image.png" description_file_path = "Packs/DNSDB/Integrations/DNSDB_v2/DNSDB_v2_description.md" yml_file_path = "Packs/DNSDB/Integrations/DNSDB_v2/DNSDB_v2.yml" assert yml_file_path == UpdateRN.check_for_release_notes_valid_file_path(image_file_path) assert yml_file_path == UpdateRN.check_for_release_notes_valid_file_path(description_file_path) assert yml_file_path == UpdateRN.check_for_release_notes_valid_file_path(yml_file_path)