def has_unskipped_test_playbook(self, current_file, entity_id, file_path, test_playbook_ids=None): """Check if the content entity has at least one unskipped test playbook. Collect test playbook ids from the `tests` field in the file, merge them with provided test_playbook_ids and validate at least one is unskipped. Args: current_file: The file to check. entity_id: The id of the entity to check. file_path: The file path of the entity to check. test_playbook_ids: test_playbook_ids unrelated to `tests` field in the file. Returns: True if the content entity has at least one unskipped test playbook. """ # If it has a dynamic section tag, it shouldn't have a test playbook. if self.DYNAMIC_SECTION_TAG in current_file.get('tags', []): return True if test_playbook_ids is None: test_playbook_ids = [] test_playbooks_unskip_status = {} all_test_playbook_ids = test_playbook_ids.copy() skipped_tests = self.conf_data.get('skipped_tests', {}) # do not check this validation for ApiModules pack if get_pack_name(file_path) == API_MODULES_PACK: return self._is_valid if isinstance(current_file.get('tests'), list): all_test_playbook_ids.extend(current_file.get('tests', [])) for test_playbook_id in set(all_test_playbook_ids): if (skipped_tests and test_playbook_id in skipped_tests) or 'No test' in test_playbook_id: test_playbooks_unskip_status[test_playbook_id] = False else: test_playbooks_unskip_status[test_playbook_id] = True if not any(test_playbooks_unskip_status.values() ) and not self.has_unittest(file_path): error_message, error_code = Errors.all_entity_test_playbooks_are_skipped( entity_id) if self.handle_error(error_message, error_code, file_path=file_path): self._is_valid = False return self._is_valid