Skip to content

Commit

Permalink
Load data errors do not prevent subsequent data products from loading
Browse files Browse the repository at this point in the history
TEST: Combine load_data error test to main load_data test
  • Loading branch information
duytnguyendtn committed Aug 2, 2024
1 parent 10d712d commit d4f152a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,6 @@ def test_populate_table_url_header_fallback(self):
assert vo_plugin._populate_url_only is True
assert vo_plugin.table.headers_visible == ["URL"]

def test_load_data_error_msgs(self):
"""Tests user gets properly notified when a load_data error occurs"""
vo_plugin = self.imviz.plugins[vo_plugin_label]._obj
fake_result = fake_siaresult(
{
"title": "Fake Title",
"instr": "Fake Instrument",
"dateobs": "Fake Dateobs",
}
)
vo_plugin._populate_table([fake_result])
vo_plugin.table.selected_rows = [vo_plugin.table.items[0]] # Select first entry
with pytest.raises(ValueError):
vo_plugin.vue_load_selected_data()
assert any(
"Unable to load file to viewer" in d["text"]
for d in self.imviz.app.state.snackbar_history
)


@pytest.mark.remote_data
class TestVOImvizRemote:
Expand Down Expand Up @@ -237,9 +218,11 @@ def test_coverage_toggle(self, imviz_helper):
@pytest.mark.filterwarnings("ignore:Some non-standard WCS keywords were excluded")
def test_HSTM51_load_data(self, imviz_helper):
"""
Test the full plugin by filling out the form and loading a data product into Imviz.
Also test if the plugin warns user about potentially misaligned data layers
Tests the following:
* The full plugin by filling out the form and loading a data product into Imviz.
* The plugin warns user about potentially misaligned data layers
when loading data and WCS linking is not enabled.
* User gets properly notified when a load_data error occurs
"""
# Set Common Args
vo_plugin = self._init_voplugin_M51(imviz_helper)
Expand All @@ -255,9 +238,28 @@ def test_HSTM51_load_data(self, imviz_helper):
vo_plugin.vue_query_resource()
assert len(vo_plugin.table.items) > 0

# Load first data product
vo_plugin.table.selected_rows = [vo_plugin.table.items[0]] # Select first entry
# Add poisoned fake result
fake_result = fake_siaresult(
{
"title": "Fake Title",
"instr": "Fake Instrument",
"dateobs": "Fake Dateobs",
}
)
vo_plugin._populate_table([fake_result])

# Put the fake result first to make sure we hit the fake result before the real one
vo_plugin.table.selected_rows = [vo_plugin.table.items[-1], vo_plugin.table.items[0]] # Select first entry
assert vo_plugin.table.selected_rows[0]['URL'] == fake_result.getdataurl()

# Load first data product and fake result
vo_plugin.vue_load_selected_data()
# Test that user was warned about failed file loading on fake result
assert any(
"Unable to load file to viewer" in d["text"]
for d in imviz_helper.app.state.snackbar_history
)
# But also test that didn't prevent us from loading the valid results
assert len(imviz_helper.app.data_collection) == 1
assert "M51_HST.M51" in imviz_helper.data_labels[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def vue_load_selected_data(self, _=None):
color="error",
)
)
raise e
# Clear selected entries' checkboxes on table
self.table.selected_rows = []
self.data_loading = False # Stop loading spinner

0 comments on commit d4f152a

Please sign in to comment.