Skip to content

Commit

Permalink
correct entry-points and add respective test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Oct 17, 2023
1 parent 85f5ad1 commit 337d3d4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions iblrig/test/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest
from importlib.metadata import entry_points
from typing import Callable


class TestEntryPoints(unittest.TestCase):

def test_entry_points(self) -> None:
"""
Test iblrig's console_scripts entry points
The method collects the names and loaded entry points of iblrig scripts
and performs assertions or checks based on the loaded entry points.
Raises:
AssertionError: If loaded entry points are not callable.
"""
iblrig_scripts = []
for ep in entry_points(group='console_scripts'):
if ep.value.startswith('iblrig.'):
try:
loaded_ep = ep.load()
iblrig_scripts.append((ep.name, loaded_ep))
except Exception as e:
print(f"Error loading entry point '{ep.name}': {str(e)}")

assert all(isinstance(script[1], Callable) for script in iblrig_scripts), "Loaded entry points are not callable."
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ flush = "iblrig.commands:flush"
remove-old-sessions = "iblrig.commands:remove_local_sessions"
iblrig = "iblrig.gui.wizard:main"
upgrade_iblrig = "iblrig.version_management:upgrade"
install_spinnaker = "iblrig.video:install_spinnaker_sdk"
install_spinnaker = "iblrig.camera:install_spinnaker_sdk"

[tool.setuptools.dynamic]
readme = {file = "README.md", content-type = "text/markdown"}
Expand Down

0 comments on commit 337d3d4

Please sign in to comment.