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_ident_changed_file_type_layouts(self, mocker): """ Given: - a filepath of a changed file When: - determining the type of item changed (e.g. Integration, Script, Layout, etc.) Then: - return tuple where first value is the pack name, and second is the item type """ expected_result = ('VulnDB', 'Layout') from demisto_sdk.commands.update_release_notes.update_rn import UpdateRN update_rn = UpdateRN(pack="VulnDB", update_type='minor', pack_files={'HelloWorld'}, added_files=set()) filepath = os.path.join(TestRNUpdate.FILES_PATH, 'Layouts/VulnDB/VulnDB.json') mocker.patch.object(UpdateRN, 'find_corresponding_yml', return_value='Integrations/VulnDB/VulnDB.yml') mocker.patch.object(UpdateRN, 'get_display_name', return_value='VulnDB') result = update_rn.identify_changed_file_type(filepath) assert expected_result == result
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: if not any(permitted_type in file for permitted_type in VALIDATED_PACK_ITEM_TYPES): continue elif self.pack_name in file: update_rn_util = UpdateRN(pack=self.pack_name, pack_files=set(), update_type=None, added_files=set()) file_name, file_type = update_rn_util.identify_changed_file_type(file) if file_name and file_type: if (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.file_path): is_valid = False return is_valid
def test_ident_changed_file_type_release_notes(self): """ Given: - a filepath of a changed file When: - determining the type of item changed (e.g. Integration, Script, Layout, etc.) Then: - return tuple where first value is the pack name, and second is the item type """ expected_result = ('N/A', None) from demisto_sdk.commands.update_release_notes.update_rn import UpdateRN update_rn = UpdateRN(pack="VulnDB", update_type='minor', pack_files={'HelloWorld'}, added_files=set()) filepath = os.path.join(TestRNUpdate.FILES_PATH, 'ReleaseNotes/1_0_1.md') result = update_rn.identify_changed_file_type(filepath) assert expected_result == result