Skip to content

Commit

Permalink
Add basic tests for volume exporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed May 24, 2024
1 parent f00f659 commit 8b0b614
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions glue_plotly/html_exporters/qt/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from glue_plotly.sort_components import SortComponentsDialog
from qtpy.QtWidgets import QMessageBox

from glue_plotly.volume_options import VolumeOptionsDialog


class TestQtExporter:

Expand Down Expand Up @@ -47,6 +49,7 @@ def export_figure(self, tmpdir, output_filename):
fd.return_value = output_path, 'html'
with patch.object(SaveHoverDialog, 'exec_', self.auto_accept_selectdialog()), \
patch.object(SortComponentsDialog, 'exec_', self.auto_accept_selectdialog()), \
patch.object(VolumeOptionsDialog, 'exec_', self.auto_accept_messagebox()), \
patch.object(QMessageBox, 'exec_', self.auto_accept_messagebox()):
self.tool.activate()
return output_path
30 changes: 30 additions & 0 deletions glue_plotly/html_exporters/qt/tests/test_volume.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

from glue.core import Data

from pytest import importorskip

importorskip('glue_qt')
importorskip('glue_vispy_viewers')

from glue_vispy_viewers.volume.volume_viewer import VispyVolumeViewer # noqa: E402

from numpy import arange, ones # noqa: E402

from .test_base import TestQtExporter # noqa: E402


class TestVolume(TestQtExporter):

viewer_type = VispyVolumeViewer
tool_id = 'save:plotlyvolume'

def make_data(self):
return Data(label='d1',
x=arange(24).reshape((2, 3, 4)),
y=ones((2, 3, 4)),
z=arange(100, 124).reshape((2, 3, 4)))

def test_default(self, tmpdir):
output_path = self.export_figure(tmpdir, 'test.html')
assert os.path.exists(output_path)
3 changes: 3 additions & 0 deletions glue_plotly/volume_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from glue_plotly.html_exporters.qt.utils import layer_label


__all__ = ["VolumeOptionsDialog"]


class VolumeDialogState(State):

layer = SelectionCallbackProperty()
Expand Down

0 comments on commit 8b0b614

Please sign in to comment.