def test_final_compose(self): expected_contents = [ 'failed', 'fixed', 'needs_action', 'needs_inspection', 'not_applicable', 'pass' ] for content in expected_contents: compose_xml = ComposeXML() dir_name = os.path.join(self.temp_dir, FOO_DIR, 'dummy') compose_xml.collect_group_xmls(dir_name, content=content) xccdf_compose = XCCDFCompose(os.path.join(self.temp_dir, FOO_DIR)) xccdf_compose.generate_xml() all_xccdf = os.path.join(self.result_dir, settings.content_file) self.assertTrue(os.path.exists(all_xccdf)) dummy_lines = utils.get_file_content(all_xccdf, 'rb')
def generate_report(self): """Function generates report""" scenario = self.get_scenario() scenario_path = os.path.join(self.conf.source_dir, scenario) assessment_dir = os.path.join(self.conf.result_dir, self.get_proper_scenario(scenario)) dir_util.copy_tree(scenario_path, assessment_dir) # Try copy directory with contents to /root/preupgrade # Call xccdf_compose API for generating all-xccdf.xml if not self.conf.contents: xccdf_compose = XCCDFCompose(assessment_dir) generated_dir = xccdf_compose.generate_xml(generate_from_ini=False) if os.path.isdir(assessment_dir): shutil.rmtree(assessment_dir) shutil.move(generated_dir, assessment_dir) self.common.prep_symlinks(assessment_dir, scenario=self.get_proper_scenario(scenario)) if not self.conf.contents: utils.update_platform(os.path.join(assessment_dir, settings.content_file)) else: utils.update_platform(self.content) assessment_dir = os.path.dirname(self.content) return assessment_dir