def test_output_function_outputs_json_as_json_string(capsys): cli.handle_output(DATA, "JSON", "list") out, _ = capsys.readouterr() json_data = json.loads(out) assert json_data == DATA
def test_output_function_outputs_json_as_json_string(capsys): cli.handle_output(data, 'JSON') out, _ = capsys.readouterr() json_data = json.loads(out) assert json_data == data
def test_output_function_outputs_json_as_table_with_no_header(capsys): expected_output_lines = [ "fake-id TXT fake.example.com fake 3600", "fake2-id TXT fake2.example.com fake2 3600", ] cli.handle_output(DATA, "TABLE-NO-HEADER", "list") assert_correct_output(capsys, expected_output_lines)
def test_output_function_outputs_json_as_table_with_no_header(capsys): expected_output_lines = [ 'fake-id TXT fake.example.com fake 3600', 'fake2-id TXT fake2.example.com fake2 3600', ] cli.handle_output(data, 'TABLE-NO-HEADER') assert_correct_output(capsys, expected_output_lines)
def test_output_function_outputs_json_as_table(capsys): expected_output_lines = [ "ID TYPE NAME CONTENT TTL ", "-------- ---- ----------------- ------- ----", "fake-id TXT fake.example.com fake 3600", "fake2-id TXT fake2.example.com fake2 3600", ] cli.handle_output(DATA, "TABLE", "list") assert_correct_output(capsys, expected_output_lines)
def test_output_function_outputs_json_as_table(capsys): expected_output_lines = [ 'ID TYPE NAME CONTENT TTL ', '-------- ---- ----------------- ------- ----', 'fake-id TXT fake.example.com fake 3600', 'fake2-id TXT fake2.example.com fake2 3600', ] cli.handle_output(data, 'TABLE') assert_correct_output(capsys, expected_output_lines)
def test_output_function_outputs_nothing_with_not_a_json_serializable(capsys): expected_output_lines = [] cli.handle_output(object(), "TABLE", "list") assert_correct_output(capsys, expected_output_lines) cli.handle_output(object(), "TABLE-NO-HEADER", "list") assert_correct_output(capsys, expected_output_lines) cli.handle_output(object(), "JSON", "list") assert_correct_output(capsys, expected_output_lines)
def test_output_function_outputs_nothing_with_not_a_json_data(capsys): expected_output_lines = [] cli.handle_output(True, 'TABLE') assert_correct_output(capsys, expected_output_lines) cli.handle_output(True, 'TABLE-NO-HEADER') assert_correct_output(capsys, expected_output_lines) cli.handle_output(True, 'JSON') assert_correct_output(capsys, expected_output_lines)
def test_output_function_output_nothing_when_quiet(capsys): expected_output_lines = [] cli.handle_output(DATA, "QUIET", "list") assert_correct_output(capsys, expected_output_lines)
def test_output_function_output_nothing_when_quiet(capsys): expected_output_lines = [] cli.handle_output(data, 'QUIET') assert_correct_output(capsys, expected_output_lines)