diff --git a/server/mf.py b/server/mf.py index 8c60b77..3db34ca 100644 --- a/server/mf.py +++ b/server/mf.py @@ -4,6 +4,7 @@ between the REST API and the CLI; musicfetch itself is unchanged.""" import importlib.machinery import importlib.util import os +import sys _HERE = os.path.dirname(os.path.abspath(__file__)) _MF_PATH = os.environ.get("MUSICFETCH_BIN", os.path.join(_HERE, "..", "musicfetch")) @@ -14,6 +15,7 @@ _loader = importlib.machinery.SourceFileLoader("musicfetch_core", _MF_PATH) _spec = importlib.util.spec_from_loader("musicfetch_core", _loader) _mod = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(_mod) # safe: musicfetch guards main() behind __main__ +sys.modules["musicfetch_core"] = _mod Hit = _mod.Hit build_combined_hits = _mod.build_combined_hits @@ -22,3 +24,6 @@ act_youtube = _mod.act_youtube act_lidarr_album = _mod.act_lidarr_album act_lidarr_artist = _mod.act_lidarr_artist QUALITY_CHOICES = _mod.QUALITY_CHOICES + +__all__ = ["Hit", "build_combined_hits", "pick", "act_youtube", + "act_lidarr_album", "act_lidarr_artist", "QUALITY_CHOICES"] diff --git a/tests/test_mf_loader.py b/tests/test_mf_loader.py index 21d3e4e..6115136 100644 --- a/tests/test_mf_loader.py +++ b/tests/test_mf_loader.py @@ -1,3 +1,6 @@ +"""Tests for the server.mf loader.""" + + def test_mf_reexports_musicfetch_symbols(): from server import mf assert hasattr(mf, "Hit") @@ -6,6 +9,7 @@ def test_mf_reexports_musicfetch_symbols(): assert callable(mf.act_youtube) assert callable(mf.act_lidarr_album) assert callable(mf.act_lidarr_artist) + assert isinstance(mf.QUALITY_CHOICES, list) def test_mf_hit_constructs():