Skip to content

Commit

Permalink
Finished testing of fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cadea authored and cadea committed Mar 7, 2024
1 parent 6ca596a commit d0d35a2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/test_fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,30 @@ def test_print_json_with_indent():
def test_print_json_without_indent():
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
with patch("fractal.cli.fmt.json.dumps") as mock_dump:
fmt.print_json(data=data, indent=None)
fmt.print_json(data=data, indent=0)
mock_dump.assert_called_once_with(data, default=str)


def test_display_data_format_is_json():
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
with patch("fractal.cli.fmt.print_json") as mock_print_json:
fmt.display_data(data=data, format="json")
mock_print_json.assert_called_once_with(data)


def test_display_data_format_is_table():
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
title = "Test title"
exclude_list = ["key2"]
with patch("fractal.cli.fmt.print_json_to_table") as mock_print_json_to_table:
fmt.display_data(data=data, title=title, exclude=exclude_list)
mock_print_json_to_table.assert_called_once_with(title, data, exclude_list)


def test_display_data_format_is_unsupported_display():
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
title = "Test title"
exclude_list = ["key2"]
with patch("fractal.cli.fmt.print_json_to_table") as mock_print_json_to_table:
fmt.display_data(data=data, title=title, format="invalid", exclude=exclude_list)
mock_print_json_to_table.assert_called_once_with(title, data, exclude_list)

0 comments on commit d0d35a2

Please sign in to comment.