Skip to content

Commit

Permalink
Test setting and getting plot resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrost-mo committed Aug 20, 2024
1 parent 690cf9a commit 5b59f5e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/operators/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,17 @@ def test_scatter_plot_too_many_y_dimensions(
cube_x = collapse.collapse(vertical_profile_cube, ["time"], "MEAN")[0:4]
with pytest.raises(ValueError):
plot.scatter_plot(cube_x, cube_y)


def test_get_plot_resolution(tmp_working_dir):
"""Test getting the plot resolution."""
with open("meta.json", "wt", encoding="UTF-8") as fp:
fp.write('{"plot_resolution": 72}')
resolution = plot._get_plot_resolution()
assert resolution == 72


def test_get_plot_resolution_unset(tmp_working_dir):
"""Test getting the default plot resolution when unset."""
resolution = plot._get_plot_resolution()
assert resolution == 100
8 changes: 8 additions & 0 deletions tests/test_run_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ def test_run_steps_style_file_metadata_written(tmp_path: Path):
with open(tmp_path / "meta.json", "rb") as fp:
metadata = json.load(fp)
assert metadata["style_file_path"] == style_file_path


def test_run_steps_plot_resolution_metadata_written(tmp_path: Path):
"""Style file path metadata written out."""
CSET.operators._run_steps({}, [], None, tmp_path, plot_resolution=72)
with open(tmp_path / "meta.json", "rb") as fp:
metadata = json.load(fp)
assert metadata["plot_resolution"] == 72

0 comments on commit 5b59f5e

Please # to comment.