def test_make_all_reports_does_not_recreate_existing_reports(self): # Edith creates a report with a standard path result = runcmd(self, slm.cli, "frotz", "create-report", "--scan_id", "1", "--report_format", "xlsx") # She checks to make sure, and indeed the report is there self.assertEqual(0, result.exit_code) p1 = os.path.join("projects", "frotz", "subprojects", "frotz-nuclear", "reports", "frotz-nuclear-2018-01-26.xlsx") checkForFileExists(self, self.slmhome, p1) # Now she wants to automatically have all types of reports created # for all currently-imported scans, for this project, but the # first report shouldn't be re-created result = runcmd(self, slm.cli, "frotz", "create-reports") # The output message tells her it succeeded and that only 3 reports # were created self.assertEqual(0, result.exit_code) self.assertEqual("3 reports successfully created\n", result.output) # She checks to make sure, and indeed the new reports are there checkForFileExists(self, self.slmhome, p1) p2 = os.path.join("projects", "frotz", "subprojects", "frotz-nuclear", "reports", "frotz-nuclear-2018-01-26.json") checkForFileExists(self, self.slmhome, p2) p3 = os.path.join("projects", "frotz", "subprojects", "frotz-dim", "reports", "frotz-dim-2018-02-06.xlsx") checkForFileExists(self, self.slmhome, p3) p4 = os.path.join("projects", "frotz", "subprojects", "frotz-dim", "reports", "frotz-dim-2018-02-06.json") checkForFileExists(self, self.slmhome, p4)
def test_can_create_new_project_and_subproject(self): # Edith is starting to manage licenses for a new project called yozozzo. # She asks SLM to create a new project result = runcmd(self, slm.cli, None, "create-project", "yozozzo", '--desc="The YOZOZZO Project"') self.assertEqual(0, result.exit_code) # She confirms that the SLM top-level configuration file has been updated # and now refers to yozozzo checkForTextInFile(self, self.slmhome, "slmconfig.json", "yozozzo") # She also confirms that the appropriate subdirectory and database have # been created checkForDirectoryExists(self, self.slmhome, "projects/yozozzo") checkForFileExists(self, self.slmhome, "projects/yozozzo/yozozzo.db") # And she confirms that a "reports/" subdirectory has been created for this # project checkForDirectoryExists(self, self.slmhome, "projects/yozozzo/reports") # And she confirms that a "subprojects/" subdirectory has been created for this # project checkForDirectoryExists(self, self.slmhome, "projects/yozozzo/subprojects") # And she confirms that a "list" command now includes yozozzo in the list result = runcmd(self, slm.cli, None, "list") self.assertEqual(0, result.exit_code) self.assertEqual("frotz\ngnusto\nrezrov\nyozozzo\n", result.output) # Now, she wants to create its first subproject, yozozzo-duck result = runcmd(self, slm.cli, "yozozzo", "create-subproject", "yozozzo-duck", '--desc="Duck transformation spell"') self.assertEqual(0, result.exit_code) # She confirms that the appropriate subproject subdirectories have # been created checkForDirectoryExists(self, self.slmhome, "projects/yozozzo/subprojects/yozozzo-duck") # And she confirms that the appropriate subdirectories have been created # for this subproject checkForDirectoryExists(self, self.slmhome, "projects/yozozzo/subprojects/yozozzo-duck/spdx") checkForDirectoryExists(self, self.slmhome, "projects/yozozzo/subprojects/yozozzo-duck/reports") # And she confirms that a "list" command now includes yozozzo-duck result = runcmd(self, slm.cli, "yozozzo", "list") self.assertEqual(0, result.exit_code) self.assertEqual("yozozzo/yozozzo-duck\n", result.output)
def test_can_omit_report_path_and_get_default_location_and_name(self): # Edith chooses not to include a --report-path flag result = runcmd(self, slm.cli, "frotz", "create-report", "--scan_id", "1", "--report_format", "xlsx") # The output message tells her it succeeded, and that the report is in # the expected path and has the expected filename self.assertEqual(0, result.exit_code) expectedPath = os.path.join("projects", "frotz", "subprojects", "frotz-nuclear", "reports", "frotz-nuclear-2018-01-26.xlsx") fullPath = os.path.join(self.slmhome, expectedPath) self.assertEqual(f"Report successfully created at {fullPath}.\n", result.output) # She checks to make sure, and indeed the report is there checkForFileExists(self, self.slmhome, expectedPath)
def test_can_make_all_reports(self): # Edith wants to automatically have all types of reports created for # all currently-imported scans, for this project, that haven't already # been created with default paths result = runcmd(self, slm.cli, "frotz", "create-reports") # The output message tells her it succeeded self.assertEqual(0, result.exit_code) self.assertEqual("4 reports successfully created\n", result.output) # She checks to make sure, and indeed the reports are there p1 = os.path.join("projects", "frotz", "subprojects", "frotz-nuclear", "reports", "frotz-nuclear-2018-01-26.xlsx") checkForFileExists(self, self.slmhome, p1) p2 = os.path.join("projects", "frotz", "subprojects", "frotz-nuclear", "reports", "frotz-nuclear-2018-01-26.json") checkForFileExists(self, self.slmhome, p2) p3 = os.path.join("projects", "frotz", "subprojects", "frotz-dim", "reports", "frotz-dim-2018-02-06.xlsx") checkForFileExists(self, self.slmhome, p3) p4 = os.path.join("projects", "frotz", "subprojects", "frotz-dim", "reports", "frotz-dim-2018-02-06.json") checkForFileExists(self, self.slmhome, p4)