Skip to content

Commit 1297699

Browse files
committed
Add test that get_viewport result can be used to set_viewport
1 parent 66b158c commit 1297699

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/astro_image_display_api/widget_api_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ def test_get_viewport_no_sky_or_pixel(self, data, wcs, sky_or_pixel):
256256
assert isinstance(vport['center'], tuple)
257257
assert isinstance(vport['fov'], float)
258258

259+
def test_viewport_round_trips(self, data, wcs):
260+
# Check that the viewport retrieved with get can be used to set
261+
# the viewport again, and that the values are the same.
262+
self.image.load_image(NDData(data=data, wcs=wcs), image_label='test')
263+
self.image.set_viewport(center=(10, 10), fov=100, image_label='test')
264+
vport = self.image.get_viewport(image_label='test')
265+
# Set the viewport again using the values from the get_viewport
266+
self.image.set_viewport(**vport)
267+
# Get the viewport again and check that the values are the same
268+
vport2 = self.image.get_viewport(image_label='test')
269+
assert vport2 == vport
270+
259271
def test_marker_properties(self):
260272
# Set the marker style
261273
marker_style = {'color': 'yellow', 'radius': 10, 'type': 'cross'}

0 commit comments

Comments
 (0)