def test_output_issue(self, get_code): issue = _get_issue_instance() get_code.return_value = "DDDDDDD" indent_val = "CCCCCCC" def _template(_issue, _indent_val, _code, _color): return_val = [ "{}{}>> Issue: [{}:{}] {}".format( _indent_val, _color, _issue.test_id, _issue.test, _issue.text, ), "{} Severity: {} CWE: {} Confidence: {}".format( _indent_val, _issue.severity.capitalize(), _issue.cwe, _issue.confidence.capitalize(), ), "{} Location: {}:{}:{}".format( _indent_val, _issue.fname, _issue.lineno, _issue.col_offset ), "{} More Info: {}{}".format( _indent_val, docs_utils.get_url(_issue.test_id), screen.COLOR["DEFAULT"], ), ] if _code: return_val.append(f"{_indent_val}{_code}") return "\n".join(return_val) issue_text = screen._output_issue_str(issue, indent_val) expected_return = _template( issue, indent_val, "DDDDDDD", screen.COLOR["MEDIUM"] ) self.assertEqual(expected_return, issue_text) issue_text = screen._output_issue_str( issue, indent_val, show_code=False ) expected_return = _template( issue, indent_val, "", screen.COLOR["MEDIUM"] ) self.assertEqual(expected_return, issue_text) issue.lineno = "" issue.col_offset = "" issue_text = screen._output_issue_str( issue, indent_val, show_lineno=False ) expected_return = _template( issue, indent_val, "DDDDDDD", screen.COLOR["MEDIUM"] ) self.assertEqual(expected_return, issue_text)
def test_output_issue(self, get_code): issue = _get_issue_instance() get_code.return_value = 'DDDDDDD' indent_val = 'CCCCCCC' def _template(_issue, _indent_val, _code, _color): return_val = [ "{}{}>> Issue: [{}:{}] {}".format(_indent_val, _color, _issue.test_id, _issue.test, _issue.text), "{} Severity: {} Confidence: {}".format( _indent_val, _issue.severity.capitalize(), _issue.confidence.capitalize()), "{} Location: {}:{}:{}".format(_indent_val, _issue.fname, _issue.lineno, _issue.col_offset), "{} More Info: {}{}".format( _indent_val, docs_utils.get_url(_issue.test_id), screen.COLOR['DEFAULT']) ] if _code: return_val.append("{}{}".format(_indent_val, _code)) return '\n'.join(return_val) issue_text = screen._output_issue_str(issue, indent_val) expected_return = _template(issue, indent_val, 'DDDDDDD', screen.COLOR['MEDIUM']) self.assertEqual(expected_return, issue_text) issue_text = screen._output_issue_str(issue, indent_val, show_code=False) expected_return = _template(issue, indent_val, '', screen.COLOR['MEDIUM']) self.assertEqual(expected_return, issue_text) issue.lineno = '' issue.col_offset = '' issue_text = screen._output_issue_str(issue, indent_val, show_lineno=False) expected_return = _template(issue, indent_val, 'DDDDDDD', screen.COLOR['MEDIUM']) self.assertEqual(expected_return, issue_text)
def test_output_issue(self, get_code): issue = _get_issue_instance() get_code.return_value = 'DDDDDDD' indent_val = 'CCCCCCC' def _template(_issue, _indent_val, _code, _color): return_val = ["{}{}>> Issue: [{}:{}] {}". format(_indent_val, _color, _issue.test_id, _issue.test, _issue.text), "{} Severity: {} Confidence: {}". format(_indent_val, _issue.severity.capitalize(), _issue.confidence.capitalize()), "{} Location: {}:{}{}". format(_indent_val, _issue.fname, _issue.lineno, screen.color['DEFAULT'])] if _code: return_val.append("{}{}".format(_indent_val, _code)) return '\n'.join(return_val) issue_text = screen._output_issue_str(issue, indent_val) expected_return = _template(issue, indent_val, 'DDDDDDD', screen.color['MEDIUM']) self.assertEqual(expected_return, issue_text) issue_text = screen._output_issue_str(issue, indent_val, show_code=False) expected_return = _template(issue, indent_val, '', screen.color['MEDIUM']) self.assertEqual(expected_return, issue_text) issue.lineno = '' issue_text = screen._output_issue_str(issue, indent_val, show_lineno=False) expected_return = _template(issue, indent_val, 'DDDDDDD', screen.color['MEDIUM']) self.assertEqual(expected_return, issue_text)