def summarize(self): """Summarize completed test report cases for all groups Aggregates ReportSummary objects for each group in the Report's "groups" list into a single ReportSummary. Sets this to the Report object's "summary" attribute """ summary = ReportSummary() [summary.add_from_summary(group.summary) for group in self.groups] self.summary = summary
def test_increment_run(): """pytest: test increment_run method""" summary = ReportSummary() assert summary.get_run() == 0 summary.increment_run() assert summary.get_run() == 1 summary.increment_run() assert summary.get_run() == 2
def test_increment_failed(): """pytest: test increment_failed method""" summary = ReportSummary() assert summary.get_failed() == 0 summary.increment_failed() assert summary.get_failed() == 1 for i in range(0, 35): summary.increment_failed() assert summary.get_failed() == 36
def test_increment_warned(): """pytest: test increment_warned method""" summary = ReportSummary() assert summary.get_warned() == 0 summary.increment_warned() assert summary.get_warned() == 1 for i in range(0, 20): summary.increment_warned() assert summary.get_warned() == 21
def test_increment_skipped(): """pytest: test increment_skipped method""" summary = ReportSummary() assert summary.get_skipped() == 0 summary.increment_skipped() assert summary.get_skipped() == 1 for i in range(0, 99): summary.increment_skipped() assert summary.get_skipped() == 100
def generate_report_summary_dict(): """populate summary objects with sample status counts Returns: dict: ReportSummary objects populated with test status counts """ summaries = { "a": ReportSummary(), "b": ReportSummary(), "c": ReportSummary() } for l in ["a", "b", "c"]: summary = summaries[l] for status_string in ["passed", "warned", "failed", "skipped"]: status_int = status_ints[status_string] count = counts[l][status_string] for i in range(0, count): summary.increment(status_int) return summaries
def summarize(self): """Summarize completed test report cases for the entire group Once all ReportCase objects in the group's "cases" list are completed (ie. validation methods have been run and case object properties finalized), this method will summarize/aggregate the pass,failure, warning, skipped counts into a single ReportSummary object, which is then set to the 'summary' property. """ def increment_summary(summary_obj, case_obj): """increment ReportSummary count was ReportCase status Whatever the status of the case object, the corresponding property will be incremented by 1 in the summary object Args: summary_obj (ReportSummary): summary object to increment case_obj (ReportCase): case object """ summary_obj.increment(case_obj.get_status()) summary = ReportSummary() [increment_summary(summary, case) for case in self.cases]
def test_increment(): """pytest: test increment method""" summary = ReportSummary() summary.increment(c.RESULT_SUCCESS) assert summary.get_passed() == 1 assert summary.get_run() == 1 summary.increment(c.RESULT_FAILURE) assert summary.get_failed() == 1 assert summary.get_run() == 2 summary.increment(c.RESULT_WARNING) assert summary.get_warned() == 1 assert summary.get_run() == 3 summary.increment(c.RESULT_SKIPPED) assert summary.get_skipped() == 1 assert summary.get_run() == 4