def test_html(self, mock_open, mock_to_json): mock_open.side_effect = [ mock.mock_open(read_data="1_{{DATA}}_2").return_value ] mock_to_json.return_value = "ABC" template_path = os.path.join(os.path.dirname(reports.__file__), "templates", "report.tpl") results = mock.MagicMock() self.assertEqual("1_ABC_2", reports.to_html(results)) mock_to_json.assert_called_once_with(results) mock_open.assert_called_once_with(template_path)
def test_html(self, mock_open, mock_to_json): mock_open.side_effect = [ mock.mock_open(read_data="1_{{DATA}}_2").return_value ] mock_to_json.return_value = "ABC" template_path = os.path.join( os.path.dirname(reports.__file__), "templates", "report.tpl") results = mock.MagicMock() self.assertEqual("1_ABC_2", reports.to_html(results)) mock_to_json.assert_called_once_with(results) mock_open.assert_called_once_with(template_path)
def main(): if len(sys.argv) == 1: print_help() elif len(sys.argv) == 2: report = reports.to_json(trace_module(sys.argv[1])) sys.stdout.write(report) elif len(sys.argv) == 3: if "--html" in sys.argv[1:]: arg_pos = 1 if sys.argv[1] != "--html" else 2 report = reports.to_html(trace_module(sys.argv[arg_pos])) sys.stdout.write(report) else: print_help() raise SystemExit("Wrong input arguments: %s" % sys.argv) else: print_help() raise SystemExit("Wrong input arguments: %s" % sys.argv)