def show_testcases_status(self): # type: () -> None data = list() for t in self.configuration.test_cases: for s in self.state_graph.nodes: data += [(repr(s), t.__class__.__name__, t.has_completed(s))] make_lined_table(data, lambda tup: (tup[0], tup[1], tup[2]))
def _show_state_information(self, dump): # type: (bool) -> Optional[str] completed = [(state, self._state_completed[state]) for state in self.scanned_states] return make_lined_table( completed, lambda tup: ("Scan state completed", tup[0], tup[1]), dump=dump)
def show(self, dump=False, filtered=True, verbose=False): s = "\n\n" + "=" * (len(self.description) + 10) + "\n" s += " " * 5 + self.description + "\n" s += "-" * (len(self.description) + 10) + "\n" s += "%d requests were sent, %d answered, %d unanswered" % \ (len(self.results), self.stats["answered"], self.stats["unanswered"]) + "\n" s += "Times between request and response:\tMIN: %f\tMAX: %f\tAVG: %f" \ % (self.stats["answertime_min"], self.stats["answertime_max"], self.stats["answertime_avg"]) + "\n" s += "%d negative responses were received" % \ self.stats["negative_resps"] + "\n" if not dump: print(s) s = "" else: s += "\n" s += self.show_negative_response_details(dump) or "" + "\n" if len(self.negative_response_blacklist): s += "The following negative response codes are blacklisted: " s += "%s" % self.negative_response_blacklist + "\n" if not dump: print(s) else: s += "\n" data = self.results if not filtered else self.filtered_results if len(data): s += make_lined_table(data, self.get_table_entry, dump=dump) or "" else: s += "=== No data to display ===\n" if verbose: completed = [(x, self.state_completed[x]) for x in self.scanned_states] s += make_lined_table(completed, lambda tup: ("Scan state completed", tup[0], tup[1]), dump=dump) or "" return s if dump else None
def _show_state_information(self, **kwargs): # type: (Any) -> str completed = [(state, self._state_completed[state]) for state in self.scanned_states] return make_lined_table(completed, lambda tup: ("Scan state completed", tup[0], tup[1]), dump=True) or ""
def _show_statistics(self, **kwargs): # type: (Any) -> str stats = self._compute_statistics() s = "%d requests were sent, %d answered, %d unanswered" % \ (len(self._results), len(self.results_with_response), len(self.results_without_response)) + "\n" s += "Statistics per state\n" s += make_lined_table(stats, lambda x: x, dump=True, sortx=str, sorty=str) or "" return s + "\n"
def _show_results_information(self, **kwargs): # type: (Any) -> str def _get_table_entry( tup # type: _AutomotiveTestCaseScanResult ): # type: (...) -> Tuple[str, str, str] return self._get_table_entry_x(tup), \ self._get_table_entry_y(tup), \ self._get_table_entry_z(tup) filtered = kwargs.get("filtered", True) s = "=== No data to display ===\n" data = self._results if not filtered else self.filtered_results # type: Union[List[_AutomotiveTestCaseScanResult], List[_AutomotiveTestCaseFilteredScanResult]] # noqa: E501 if len(data): s = make_lined_table( data, _get_table_entry, dump=True, sortx=str) or "" return s + "\n"
def _show_statistics(self, dump=False): # type: (bool) -> Union[str, None] stats = self._compute_statistics() s = "%d requests were sent, %d answered, %d unanswered" % \ (len(self._results), len(self.results_with_response), len(self.results_without_response)) + "\n" s += "Statistics per state\n" s += make_lined_table( stats, lambda x: x, dump=True, sortx=str, sorty=str) or "" if dump: return s + "\n" else: print(s) return None
def _show_results_information(self, dump, filtered): # type: (bool, bool) -> Optional[str] def _get_table_entry(tup # type: _AutomotiveTestCaseScanResult ): # type: (...) -> Tuple[str, str, str] return self._get_table_entry_x(tup), \ self._get_table_entry_y(tup), \ self._get_table_entry_z(tup) s = "=== No data to display ===\n" data = self._results if not filtered else self.filtered_results # type: Union[List[_AutomotiveTestCaseScanResult], List[_AutomotiveTestCaseFilteredScanResult]] # noqa: E501 if len(data): s = make_lined_table(data, _get_table_entry, dump=dump, sortx=str) or "" if dump: return s + "\n" else: print(s) return None
def make_lined_table(self, *args, **kargs): """Same as make_table, but print a table with lines""" return make_lined_table(self.res, *args, **kargs)
def make_lined_table(self, *args, **kargs): # type: (Any, Any) -> None """Same as make_table, but print a table with lines""" return make_lined_table(self.res, *args, **kargs)
def make_lined_table(self, *args, **kargs): # type: (Any, Any) -> Optional[str] """Same as make_table, but print a table with lines""" return make_lined_table(self.res, *args, **kargs) # type: ignore