Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Mar 8, 2024
1 parent 2d48c19 commit 5fd7a8a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lcviz/plugins/binning/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from lcviz.events import EphemerisChangedMessage
from lcviz.marks import LivePreviewBinning
from lcviz.parsers import _data_with_reftime
from lcviz.viewers import TimeScatterView
from lcviz.viewers import TimeScatterView, PhaseScatterView
from lcviz.components import EphemerisSelectMixin


Expand Down Expand Up @@ -130,7 +130,7 @@ def _set_results_viewer(self, event={}):
def viewer_filter(viewer):
if self.ephemeris_selected in self.ephemeris._manual_options:
return isinstance(viewer, TimeScatterView)
if 'flux-vs-phase:' not in viewer.reference:
if not isinstance(viewer, PhaseScatterView):
# ephemeris selected, but no active phase viewers
return False
return viewer._ephemeris_component == self.ephemeris_selected
Expand Down
33 changes: 32 additions & 1 deletion lcviz/tests/test_plugin_ephemeris.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_plugin_ephemeris(helper, light_curve_like_kepler_quarter):
ephem.period = 3.14
assert len(helper.app.get_viewer_ids()) == 2
assert ephem._obj.phase_viewer_exists
assert ephem._obj.phase_viewer_id in helper.app.get_viewer_ids()
assert 'flux-vs-phase:default' in helper.app.get_viewer_ids()

ephem.t0 = 5
ephem._obj.vue_period_double()
Expand Down Expand Up @@ -90,16 +90,47 @@ def test_cloned_phase_viewer(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)
ephem = helper.plugins['Ephemeris']

assert len(ephem._obj._get_phase_viewers()) == 0
pv1 = ephem.create_phase_viewer()
assert len(ephem._obj._get_phase_viewers()) == 1
pv2 = pv1._obj.clone_viewer()
assert len(ephem._obj._get_phase_viewers()) == 2
assert len(helper.viewers) == 3
assert pv1._obj.reference_id == 'flux-vs-phase:default'
assert pv1._obj._ephemeris_component == 'default'
assert pv2._obj.reference_id == 'flux-vs-phase:default[1]'
assert pv2._obj._ephemeris_component == 'default'

# renaming ephemeris should update both labels
ephem.rename_component('default', 'renamed')
assert pv1._obj.reference_id == 'flux-vs-phase:renamed'
assert pv1._obj._ephemeris_component == 'renamed'
assert pv2._obj.reference_id == 'flux-vs-phase:renamed[1]'
assert pv2._obj._ephemeris_component == 'renamed'
assert len(ephem._obj._get_phase_viewers()) == 2

ephem.remove_component('renamed')
assert len(helper.viewers) == 1 # just flux-vs-phase


def test_create_phase_viewer(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)
ephem = helper.plugins['Ephemeris']
vc = helper._tray_tools['lcviz-viewer-creator']

assert len(vc.viewer_types) == 1 # just time viewer
_ = ephem.create_phase_viewer()
assert len(vc.viewer_types) == 2

vc.vue_create_viewer('flux-vs-phase:default')
assert len(ephem._obj._get_phase_viewers()) == 2
for pv in ephem._obj._get_phase_viewers():
assert pv._ephemeris_component == 'default'

ephem.rename_component('default', 'renamed')
assert len(vc.viewer_types) == 2
vc.vue_create_viewer('flux-vs-phase:renamed')
assert len(ephem._obj._get_phase_viewers()) == 3

for pv in ephem._obj._get_phase_viewers():
assert pv._ephemeris_component == 'renamed'
4 changes: 2 additions & 2 deletions lcviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_clone(helper, light_curve_like_kepler_quarter):
helper.load_data(light_curve_like_kepler_quarter)

def_viewer = helper.viewers['flux-vs-time']
assert def_viewer._obj._get_clone_viewer_reference() == 'flux-vs-time[1]'
assert helper._get_clone_viewer_reference(def_viewer._obj.reference) == 'flux-vs-time[1]'

new_viewer = def_viewer._obj.clone_viewer()
assert new_viewer._obj._get_clone_viewer_reference() == 'flux-vs-time[2]'
assert helper._get_clone_viewer_reference(new_viewer._obj.reference) == 'flux-vs-time[2]'

0 comments on commit 5fd7a8a

Please sign in to comment.