Skip to content

Commit

Permalink
Complete tests and revert qt_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
CyclingNinja committed Jun 4, 2024
1 parent 6404d9d commit 450e6fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions glue/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from importlib import import_module

from glue.logger import logger
from glue._plugin_helpers import REQUIRED_PLUGINS
from glue._plugin_helpers import REQUIRED_PLUGINS, REQUIRED_PLUGINS_QT


_loaded_plugins = set()
Expand Down Expand Up @@ -50,8 +50,8 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None):

if plugins_to_load is None:
plugins_to_load = [i.module for i in list(iter_plugin_entry_points())]
if plugins_to_load:
plugins_to_require = [*REQUIRED_PLUGINS]
if require_qt_plugins:
plugins_to_require = [*REQUIRED_PLUGINS, *REQUIRED_PLUGINS_QT]
else:
plugins_to_require = REQUIRED_PLUGINS
else:
Expand Down
18 changes: 15 additions & 3 deletions glue/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import patch

from glue.main import load_plugins, list_loaded_plugins, list_available_plugins
from glue._plugin_helpers import REQUIRED_PLUGINS


def test_load_plugins(capsys):
Expand Down Expand Up @@ -34,27 +35,38 @@ def test_no_duplicate_loading(capsys):
with patch.object(logger, 'info') as info:
load_plugins()

plugins = []
for acall in info.call_args_list:
plugins.append(acall[0][0])
if 'Loading plugin' in acall[0][0]:
assert 'failed' in acall[0][0]

loaded_plugins = list_loaded_plugins()
assert 'glue.plugins.wcs_autolinking' in loaded_plugins
assert 'glue.core.data_exporters' in loaded_plugins
assert 'glue.plugins.coordinate_helpers' in loaded_plugins
assert len(loaded_plugins) == 5


def test_list_loaded_plugins():
"""
Regression test for retrieving the list of currently loaded plugins
Unit test for retrieving the list of currently loaded plugins
"""
load_plugins(require_qt_plugins=False)
plugins = list_loaded_plugins()
assert isinstance(plugins, list)
assert len(plugins) == 5
for test_plugin in REQUIRED_PLUGINS:
assert test_plugin in plugins


def test_list_available_plugins():
"""
Regression test for retrieving the list of currently available plugins
Unit test for retrieving the list of currently available plugins
"""
available_plugins = list_available_plugins()
assert isinstance(available_plugins, list)
assert len(available_plugins) == 7
assert 'casa_formats_io.glue_factory' in available_plugins
assert 'glue.plugins.wcs_autolinking' in available_plugins
assert 'glue.core.data_exporters' in available_plugins
assert 'glue.plugins.coordinate_helpers' in available_plugins

0 comments on commit 450e6fd

Please sign in to comment.