Skip to content

Commit

Permalink
Add test similar to lcviz (#2747)
Browse files Browse the repository at this point in the history
* Add test similar to lcviz

* Two tests need to run
  • Loading branch information
pllim authored Mar 21, 2024
1 parent 8440a99 commit 6c09924
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions jdaviz/configs/specviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,47 @@ def test_spectrum_viewer_axis_labels(specviz_helper, input_unit, y_axis_label):
label = specviz_helper.app.get_viewer_by_id('specviz-0').figure.axes[1].label

assert (y_axis_label in label)


class TestResetLimitsTwoTests:
"""See https://github.com/spacetelescope/lcviz/pull/93"""

def test_reset_limits_01(self, specviz_helper, spectrum1d):
"""This should run first."""
specviz_helper.load_data(spectrum1d)
sv = specviz_helper.app.get_viewer("spectrum-viewer")

orig_xlims = (sv.state.x_min, sv.state.x_max)
orig_ylims = (sv.state.y_min, sv.state.y_max)
# set xmin and ymin to midpoints
new_xmin = (sv.state.x_min + sv.state.x_max) * 0.5
new_ymin = (sv.state.y_min + sv.state.y_max) * 0.5
sv.state.x_min = new_xmin
sv.state.y_min = new_ymin

sv.state._reset_x_limits()
assert sv.state.x_min == orig_xlims[0]
assert sv.state.y_min == new_ymin

sv.state._reset_y_limits()
assert sv.state.y_min == orig_ylims[0]

def test_reset_limits_02(self, specviz_helper, spectrum1d_nm):
"""This should run second and see if first polutes it."""
specviz_helper.load_data(spectrum1d_nm)
sv = specviz_helper.app.get_viewer("spectrum-viewer")

orig_xlims = (sv.state.x_min, sv.state.x_max)
orig_ylims = (sv.state.y_min, sv.state.y_max)
# set xmin and ymin to midpoints
new_xmin = (sv.state.x_min + sv.state.x_max) * 0.5
new_ymin = (sv.state.y_min + sv.state.y_max) * 0.5
sv.state.x_min = new_xmin
sv.state.y_min = new_ymin

sv.state._reset_x_limits()
assert sv.state.x_min == orig_xlims[0]
assert sv.state.y_min == new_ymin

sv.state._reset_y_limits()
assert sv.state.y_min == orig_ylims[0]

0 comments on commit 6c09924

Please sign in to comment.