diff --git a/README.md b/README.md index fb12538..44f9e4c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# deckconnect +# knoepfe Connect and control Elgato Stream Decks diff --git a/deckconnect/default.cfg b/deckconnect/default.cfg deleted file mode 100644 index 7ab9088..0000000 --- a/deckconnect/default.cfg +++ /dev/null @@ -1,33 +0,0 @@ -config({ - 'type': 'deckconnect.config.device', - 'brightness': 100, - 'sleep_timeout': 10.0, - 'device_poll_frequency': 5, -}) - -config({ - 'type': 'deckconnect.widgets.obs.config', - 'host': 'localhost', - 'port': 4444, - 'password': 'supersecret', -}) - -default_deck({ - 'id': 'main', - 'widgets': [ - widget({'type': 'deckconnect.widgets.MicMute'}), - widget({'type': 'deckconnect.widgets.Timer'}), - widget({'type': 'deckconnect.widgets.Clock', 'format': '%H:%M'}), - widget({'type': 'deckconnect.widgets.obs.Recording'}), - widget({'type': 'deckconnect.widgets.obs.Streaming'}), - widget({'type': 'deckconnect.widgets.obs.CurrentScene', 'switch_deck': 'scenes'}), - ], -}) - -deck({ - 'id': 'scenes', - 'widgets': [ - widget({'type': 'deckconnect.widgets.obs.SwitchScene', 'scene': 'Scene', 'switch_deck': 'main'}), - widget({'type': 'deckconnect.widgets.obs.SwitchScene', 'scene': 'Other Scene', 'switch_deck': 'main'}), - ], -}) diff --git a/deckconnect/widgets/__init__.py b/deckconnect/widgets/__init__.py deleted file mode 100644 index 775cb79..0000000 --- a/deckconnect/widgets/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from deckconnect.widgets.clock import Clock -from deckconnect.widgets.mic_mute import MicMute -from deckconnect.widgets.text import Text -from deckconnect.widgets.timer import Timer - -__all__ = ["Text", "MicMute", "Clock", "Timer"] diff --git a/deckconnect/widgets/obs/__init__.py b/deckconnect/widgets/obs/__init__.py deleted file mode 100644 index 7df5f08..0000000 --- a/deckconnect/widgets/obs/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from deckconnect.widgets.obs.connector import config -from deckconnect.widgets.obs.current_scene import CurrentScene -from deckconnect.widgets.obs.recording import Recording -from deckconnect.widgets.obs.streaming import Streaming -from deckconnect.widgets.obs.switch_scene import SwitchScene - -__all__ = ["config", "Recording", "Streaming", "CurrentScene", "SwitchScene"] diff --git a/deckconnect/MaterialIcons-Regular.codepoints b/knoepfe/MaterialIcons-Regular.codepoints similarity index 100% rename from deckconnect/MaterialIcons-Regular.codepoints rename to knoepfe/MaterialIcons-Regular.codepoints diff --git a/deckconnect/MaterialIcons-Regular.ttf b/knoepfe/MaterialIcons-Regular.ttf similarity index 100% rename from deckconnect/MaterialIcons-Regular.ttf rename to knoepfe/MaterialIcons-Regular.ttf diff --git a/deckconnect/Roboto-Regular.ttf b/knoepfe/Roboto-Regular.ttf similarity index 100% rename from deckconnect/Roboto-Regular.ttf rename to knoepfe/Roboto-Regular.ttf diff --git a/deckconnect/__init__.py b/knoepfe/__init__.py similarity index 100% rename from deckconnect/__init__.py rename to knoepfe/__init__.py diff --git a/deckconnect/__main__.py b/knoepfe/__main__.py similarity index 86% rename from deckconnect/__main__.py rename to knoepfe/__main__.py index bfedf57..105f202 100644 --- a/deckconnect/__main__.py +++ b/knoepfe/__main__.py @@ -1,11 +1,11 @@ -"""deckconnect +"""knoepfe Connect and control Elgato Stream Decks Usage: - deckconnect [(-v | --verbose)] [--config=] - deckconnect (-h | --help) - deckconnect --version + knoepfe [(-v | --verbose)] [--config=] + knoepfe (-h | --help) + knoepfe --version Options: -h --help Show this screen. @@ -24,10 +24,10 @@ from StreamDeck.Devices import StreamDeck from StreamDeck.Transport.Transport import TransportError -from deckconnect import __version__, log -from deckconnect.config import process_config -from deckconnect.deckmanager import DeckManager -from deckconnect.log import debug, error, info +from knoepfe import __version__, log +from knoepfe.config import process_config +from knoepfe.deckmanager import DeckManager +from knoepfe.log import debug, error, info async def connect_device() -> StreamDeck: diff --git a/deckconnect/config.py b/knoepfe/config.py similarity index 97% rename from deckconnect/config.py rename to knoepfe/config.py index 46ebf02..2757b3d 100644 --- a/deckconnect/config.py +++ b/knoepfe/config.py @@ -5,8 +5,8 @@ import appdirs from schema import And, Optional, Schema -from deckconnect.deck import Deck -from deckconnect.widgets.base import Widget +from knoepfe.deck import Deck +from knoepfe.widgets.base import Widget DeckConfig = TypedDict("DeckConfig", {"id": str, "widgets": List[Widget | None]}) diff --git a/deckconnect/deck.py b/knoepfe/deck.py similarity index 92% rename from deckconnect/deck.py rename to knoepfe/deck.py index bb6db6b..0cff3f2 100644 --- a/deckconnect/deck.py +++ b/knoepfe/deck.py @@ -4,12 +4,12 @@ from StreamDeck.Devices import StreamDeck -from deckconnect.key import Key -from deckconnect.log import debug -from deckconnect.wakelock import WakeLock +from knoepfe.key import Key +from knoepfe.log import debug +from knoepfe.wakelock import WakeLock if TYPE_CHECKING: # pragma: no cover - from deckconnect.widgets.base import Widget + from knoepfe.widgets.base import Widget class SwitchDeckException(BaseException): diff --git a/deckconnect/deckmanager.py b/knoepfe/deckmanager.py similarity index 94% rename from deckconnect/deckmanager.py rename to knoepfe/deckmanager.py index d0900da..b533dc2 100644 --- a/deckconnect/deckmanager.py +++ b/knoepfe/deckmanager.py @@ -4,9 +4,9 @@ from StreamDeck.Devices import StreamDeck -from deckconnect.deck import Deck, SwitchDeckException -from deckconnect.log import debug, error -from deckconnect.wakelock import WakeLock +from knoepfe.deck import Deck, SwitchDeckException +from knoepfe.log import debug, error +from knoepfe.wakelock import WakeLock class DeckManager: @@ -19,7 +19,7 @@ def __init__( ) -> None: self.active_deck = active_deck self.decks = decks - device_config = global_config.get("deckconnect.config.device", {}) + device_config = global_config.get("knoepfe.config.device", {}) self.brightness = device_config.get("brightness", 100) self.device_poll_frequency = device_config.get("device_poll_frequency", 5) self.sleep_timeout = device_config.get("sleep_timeout", None) diff --git a/knoepfe/default.cfg b/knoepfe/default.cfg new file mode 100644 index 0000000..71d09f4 --- /dev/null +++ b/knoepfe/default.cfg @@ -0,0 +1,33 @@ +config({ + 'type': 'knoepfe.config.device', + 'brightness': 100, + 'sleep_timeout': 10.0, + 'device_poll_frequency': 5, +}) + +config({ + 'type': 'knoepfe.widgets.obs.config', + 'host': 'localhost', + 'port': 4444, + 'password': 'supersecret', +}) + +default_deck({ + 'id': 'main', + 'widgets': [ + widget({'type': 'knoepfe.widgets.MicMute'}), + widget({'type': 'knoepfe.widgets.Timer'}), + widget({'type': 'knoepfe.widgets.Clock', 'format': '%H:%M'}), + widget({'type': 'knoepfe.widgets.obs.Recording'}), + widget({'type': 'knoepfe.widgets.obs.Streaming'}), + widget({'type': 'knoepfe.widgets.obs.CurrentScene', 'switch_deck': 'scenes'}), + ], +}) + +deck({ + 'id': 'scenes', + 'widgets': [ + widget({'type': 'knoepfe.widgets.obs.SwitchScene', 'scene': 'Scene', 'switch_deck': 'main'}), + widget({'type': 'knoepfe.widgets.obs.SwitchScene', 'scene': 'Other Scene', 'switch_deck': 'main'}), + ], +}) diff --git a/deckconnect/key.py b/knoepfe/key.py similarity index 100% rename from deckconnect/key.py rename to knoepfe/key.py diff --git a/deckconnect/log.py b/knoepfe/log.py similarity index 100% rename from deckconnect/log.py rename to knoepfe/log.py diff --git a/deckconnect/wakelock.py b/knoepfe/wakelock.py similarity index 100% rename from deckconnect/wakelock.py rename to knoepfe/wakelock.py diff --git a/knoepfe/widgets/__init__.py b/knoepfe/widgets/__init__.py new file mode 100644 index 0000000..6b6faf6 --- /dev/null +++ b/knoepfe/widgets/__init__.py @@ -0,0 +1,6 @@ +from knoepfe.widgets.clock import Clock +from knoepfe.widgets.mic_mute import MicMute +from knoepfe.widgets.text import Text +from knoepfe.widgets.timer import Timer + +__all__ = ["Text", "MicMute", "Clock", "Timer"] diff --git a/deckconnect/widgets/base.py b/knoepfe/widgets/base.py similarity index 95% rename from deckconnect/widgets/base.py rename to knoepfe/widgets/base.py index 601876b..26e8cf0 100644 --- a/deckconnect/widgets/base.py +++ b/knoepfe/widgets/base.py @@ -3,9 +3,9 @@ from schema import Optional, Schema -from deckconnect.deck import SwitchDeckException -from deckconnect.key import Key -from deckconnect.wakelock import WakeLock +from knoepfe.deck import SwitchDeckException +from knoepfe.key import Key +from knoepfe.wakelock import WakeLock class Widget: diff --git a/deckconnect/widgets/clock.py b/knoepfe/widgets/clock.py similarity index 92% rename from deckconnect/widgets/clock.py rename to knoepfe/widgets/clock.py index 48123fd..42a2370 100644 --- a/deckconnect/widgets/clock.py +++ b/knoepfe/widgets/clock.py @@ -3,8 +3,8 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.base import Widget +from knoepfe.key import Key +from knoepfe.widgets.base import Widget class Clock(Widget): diff --git a/deckconnect/widgets/mic_mute.py b/knoepfe/widgets/mic_mute.py similarity index 95% rename from deckconnect/widgets/mic_mute.py rename to knoepfe/widgets/mic_mute.py index dd300eb..5720a19 100644 --- a/deckconnect/widgets/mic_mute.py +++ b/knoepfe/widgets/mic_mute.py @@ -5,9 +5,9 @@ from pulsectl_asyncio import PulseAsync from schema import Optional, Schema -from deckconnect.key import Key -from deckconnect.log import error -from deckconnect.widgets.base import Widget +from knoepfe.key import Key +from knoepfe.log import error +from knoepfe.widgets.base import Widget class MicMute(Widget): diff --git a/knoepfe/widgets/obs/__init__.py b/knoepfe/widgets/obs/__init__.py new file mode 100644 index 0000000..08229e5 --- /dev/null +++ b/knoepfe/widgets/obs/__init__.py @@ -0,0 +1,7 @@ +from knoepfe.widgets.obs.connector import config +from knoepfe.widgets.obs.current_scene import CurrentScene +from knoepfe.widgets.obs.recording import Recording +from knoepfe.widgets.obs.streaming import Streaming +from knoepfe.widgets.obs.switch_scene import SwitchScene + +__all__ = ["config", "Recording", "Streaming", "CurrentScene", "SwitchScene"] diff --git a/deckconnect/widgets/obs/base.py b/knoepfe/widgets/obs/base.py similarity index 84% rename from deckconnect/widgets/obs/base.py rename to knoepfe/widgets/obs/base.py index f588be8..eed8d81 100644 --- a/deckconnect/widgets/obs/base.py +++ b/knoepfe/widgets/obs/base.py @@ -1,8 +1,8 @@ from asyncio import Task, get_event_loop from typing import Any, Dict, List -from deckconnect.widgets.base import Widget -from deckconnect.widgets.obs.connector import obs +from knoepfe.widgets.base import Widget +from knoepfe.widgets.obs.connector import obs class OBSWidget(Widget): @@ -15,7 +15,7 @@ def __init__( self.listening_task: Task[None] | None = None async def activate(self) -> None: - await obs.connect(self.global_config.get("deckconnect.widgets.obs.config", {})) + await obs.connect(self.global_config.get("knoepfe.widgets.obs.config", {})) if not self.listening_task: self.listening_task = get_event_loop().create_task(self.listener()) diff --git a/deckconnect/widgets/obs/connector.py b/knoepfe/widgets/obs/connector.py similarity index 99% rename from deckconnect/widgets/obs/connector.py rename to knoepfe/widgets/obs/connector.py index f58e753..a253cdb 100644 --- a/deckconnect/widgets/obs/connector.py +++ b/knoepfe/widgets/obs/connector.py @@ -14,7 +14,7 @@ ) from schema import Optional, Schema -from deckconnect.log import debug, info +from knoepfe.log import debug, info config = Schema( { diff --git a/deckconnect/widgets/obs/current_scene.py b/knoepfe/widgets/obs/current_scene.py similarity index 81% rename from deckconnect/widgets/obs/current_scene.py rename to knoepfe/widgets/obs/current_scene.py index 011f31a..7cb2b7f 100644 --- a/deckconnect/widgets/obs/current_scene.py +++ b/knoepfe/widgets/obs/current_scene.py @@ -1,8 +1,8 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.obs.base import OBSWidget -from deckconnect.widgets.obs.connector import obs +from knoepfe.key import Key +from knoepfe.widgets.obs.base import OBSWidget +from knoepfe.widgets.obs.connector import obs class CurrentScene(OBSWidget): diff --git a/deckconnect/widgets/obs/recording.py b/knoepfe/widgets/obs/recording.py similarity index 93% rename from deckconnect/widgets/obs/recording.py rename to knoepfe/widgets/obs/recording.py index 9f47db6..4d1f3ac 100644 --- a/deckconnect/widgets/obs/recording.py +++ b/knoepfe/widgets/obs/recording.py @@ -3,9 +3,9 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.obs.base import OBSWidget -from deckconnect.widgets.obs.connector import obs +from knoepfe.key import Key +from knoepfe.widgets.obs.base import OBSWidget +from knoepfe.widgets.obs.connector import obs class Recording(OBSWidget): diff --git a/deckconnect/widgets/obs/streaming.py b/knoepfe/widgets/obs/streaming.py similarity index 93% rename from deckconnect/widgets/obs/streaming.py rename to knoepfe/widgets/obs/streaming.py index fdcd85b..312c724 100644 --- a/deckconnect/widgets/obs/streaming.py +++ b/knoepfe/widgets/obs/streaming.py @@ -3,9 +3,9 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.obs.base import OBSWidget -from deckconnect.widgets.obs.connector import obs +from knoepfe.key import Key +from knoepfe.widgets.obs.base import OBSWidget +from knoepfe.widgets.obs.connector import obs class Streaming(OBSWidget): diff --git a/deckconnect/widgets/obs/switch_scene.py b/knoepfe/widgets/obs/switch_scene.py similarity index 85% rename from deckconnect/widgets/obs/switch_scene.py rename to knoepfe/widgets/obs/switch_scene.py index 67d44af..5ddaede 100644 --- a/deckconnect/widgets/obs/switch_scene.py +++ b/knoepfe/widgets/obs/switch_scene.py @@ -1,8 +1,8 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.obs.base import OBSWidget -from deckconnect.widgets.obs.connector import obs +from knoepfe.key import Key +from knoepfe.widgets.obs.base import OBSWidget +from knoepfe.widgets.obs.connector import obs class SwitchScene(OBSWidget): diff --git a/deckconnect/widgets/text.py b/knoepfe/widgets/text.py similarity index 80% rename from deckconnect/widgets/text.py rename to knoepfe/widgets/text.py index 6128654..442f8bf 100644 --- a/deckconnect/widgets/text.py +++ b/knoepfe/widgets/text.py @@ -1,7 +1,7 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.base import Widget +from knoepfe.key import Key +from knoepfe.widgets.base import Widget class Text(Widget): diff --git a/deckconnect/widgets/timer.py b/knoepfe/widgets/timer.py similarity index 96% rename from deckconnect/widgets/timer.py rename to knoepfe/widgets/timer.py index e1f8624..2dc77bf 100644 --- a/deckconnect/widgets/timer.py +++ b/knoepfe/widgets/timer.py @@ -4,8 +4,8 @@ from schema import Schema -from deckconnect.key import Key -from deckconnect.widgets.base import Widget +from knoepfe.key import Key +from knoepfe.widgets.base import Widget class Timer(Widget): diff --git a/pyproject.toml b/pyproject.toml index 6bacdb7..5d11f99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] -name = "deckconnect" +name = "knoepfe" version = "0.1.0" description = "Connect and control Elgato Stream Decks" authors = ["Simon Hayessen "] license = "GPL-3.0-or-later" readme = "README.md" -homepage = "https://github.com/lnqs/deckconnect" -repository = "https://github.com/lnqs/deckconnect" +homepage = "https://github.com/lnqs/knoepfe" +repository = "https://github.com/lnqs/knoepfe" [tool.poetry.dependencies] python = "^3.10" @@ -33,14 +33,14 @@ types-Pillow = "^9.0.6" pytest-asyncio = "^0.18.1" [tool.poetry.scripts] -deckconnect = 'deckconnect.__main__:main' +knoepfe = 'knoepfe.__main__:main' [tool.isort] profile = "black" [tool.pytest.ini_options] filterwarnings = "ignore::DeprecationWarning:pulsectl_asyncio" -addopts = "--cov=deckconnect --cov-report=term-missing --asyncio-mode=auto" +addopts = "--cov=knoepfe --cov-report=term-missing --asyncio-mode=auto" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/test_config.py b/tests/test_config.py index e989edf..f92336b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -4,14 +4,14 @@ from pytest import raises from schema import Schema -from deckconnect.config import ( +from knoepfe.config import ( create_deck, create_widget, exec_config, get_config_path, process_config, ) -from deckconnect.widgets.base import Widget +from knoepfe.widgets.base import Widget test_config = """ deck({ 'widgets': [widget({'type': 'test'})] }) @@ -19,8 +19,8 @@ """ test_config_multiple_config = """ -config({ 'type': 'deckconnect.config.device', 'brightness': 100 }) -config({ 'type': 'deckconnect.config.device', 'brightness': 90 }) +config({ 'type': 'knoepfe.config.device', 'brightness': 100 }) +config({ 'type': 'knoepfe.config.device', 'brightness': 90 }) """ test_config_no_default = """ @@ -37,14 +37,14 @@ def test_config_path() -> None: assert get_config_path(Path("path")) == Path("path") with patch("pathlib.Path.exists", return_value=True): - assert str(get_config_path()).endswith(".config/deckconnect/default.cfg") + assert str(get_config_path()).endswith(".config/knoepfe/default.cfg") - assert str(get_config_path()).endswith("deckconnect/default.cfg") + assert str(get_config_path()).endswith("knoepfe/default.cfg") def test_exec_config_success() -> None: - with patch("deckconnect.config.create_deck") as create_deck, patch( - "deckconnect.config.create_widget" + with patch("knoepfe.config.create_deck") as create_deck, patch( + "knoepfe.config.create_widget" ) as create_widget: exec_config(test_config) assert create_deck.called @@ -57,37 +57,33 @@ def test_exec_config_multiple_config() -> None: def test_exec_config_multiple_default() -> None: - with patch("deckconnect.config.create_deck"), patch( - "deckconnect.config.create_widget" - ): + with patch("knoepfe.config.create_deck"), patch("knoepfe.config.create_widget"): with raises(RuntimeError): exec_config(test_config_multiple_default) def test_exec_config_invalid_global() -> None: - with patch("deckconnect.config.import_module", return_value=Mock(Class=int)): + with patch("knoepfe.config.import_module", return_value=Mock(Class=int)): with raises(RuntimeError): exec_config(test_config_multiple_config) def test_exec_config_no_default() -> None: - with patch("deckconnect.config.create_deck"), patch( - "deckconnect.config.create_widget" - ): + with patch("knoepfe.config.create_deck"), patch("knoepfe.config.create_widget"): with raises(RuntimeError): exec_config(test_config_no_default) def test_process_config() -> None: with patch( - "deckconnect.config.exec_config", return_value=(Mock(), [Mock()]) + "knoepfe.config.exec_config", return_value=(Mock(), [Mock()]) ) as exec_config, patch("builtins.open", mock_open(read_data=test_config)): process_config(Path("file")) assert exec_config.called def test_create_deck() -> None: - with patch("deckconnect.config.Deck") as deck: + with patch("knoepfe.config.Deck") as deck: create_deck({"id": "id", "widgets": []}) assert deck.called @@ -97,12 +93,12 @@ class TestWidget(Widget): def get_schema(self) -> Schema: return Schema({}) - with patch("deckconnect.config.import_module", return_value=Mock(Class=TestWidget)): + with patch("knoepfe.config.import_module", return_value=Mock(Class=TestWidget)): w = create_widget({"type": "a.b.c.Class"}, {}) assert isinstance(w, TestWidget) def test_create_widget_invalid_type() -> None: - with patch("deckconnect.config.import_module", return_value=Mock(Class=int)): + with patch("knoepfe.config.import_module", return_value=Mock(Class=int)): with raises(Exception): create_widget({"type": "a.b.c.Class"}, {}) diff --git a/tests/test_deck.py b/tests/test_deck.py index 2168f5f..87187c7 100644 --- a/tests/test_deck.py +++ b/tests/test_deck.py @@ -4,8 +4,8 @@ from pytest import raises from StreamDeck.Devices import StreamDeck -from deckconnect.deck import Deck -from deckconnect.widgets.base import Widget +from knoepfe.deck import Deck +from knoepfe.widgets.base import Widget def test_deck_init() -> None: diff --git a/tests/test_deckmanager.py b/tests/test_deckmanager.py index e2ff42d..a273719 100644 --- a/tests/test_deckmanager.py +++ b/tests/test_deckmanager.py @@ -3,8 +3,8 @@ from pytest import raises -from deckconnect.deck import Deck, SwitchDeckException -from deckconnect.deckmanager import DeckManager +from knoepfe.deck import Deck, SwitchDeckException +from knoepfe.deckmanager import DeckManager async def test_deck_manager_run() -> None: @@ -66,7 +66,7 @@ async def test_deck_manager_switch_deck() -> None: async def test_deck_manager_sleep_activation() -> None: deck = Mock(spec=Deck) deck_manager = DeckManager( - deck, [deck], {"deckconnect.config.device": {"sleep_timeout": 1.0}}, MagicMock() + deck, [deck], {"knoepfe.config.device": {"sleep_timeout": 1.0}}, MagicMock() ) deck_manager.last_action = 0.0 @@ -83,7 +83,7 @@ async def test_deck_manager_sleep_activation() -> None: async def test_deck_manager_sleep() -> None: deck_manager = DeckManager(Mock(), [], {}, MagicMock()) - with patch("deckconnect.deckmanager.sleep", AsyncMock()): + with patch("knoepfe.deckmanager.sleep", AsyncMock()): await deck_manager.sleep() assert deck_manager.sleeping diff --git a/tests/test_key.py b/tests/test_key.py index 8e4d215..915395d 100644 --- a/tests/test_key.py +++ b/tests/test_key.py @@ -1,6 +1,6 @@ from unittest.mock import DEFAULT, MagicMock, Mock, patch -from deckconnect.key import Key, Renderer +from knoepfe.key import Key, Renderer def test_renderer_text() -> None: @@ -28,21 +28,21 @@ def test_renderer_draw_text() -> None: renderer = Renderer() with patch( - "deckconnect.key.ImageDraw.Draw", + "knoepfe.key.ImageDraw.Draw", return_value=Mock(textsize=Mock(return_value=(0, 0))), ) as draw: renderer._render_text("text", "Text", size=12, color=None, valign="top") assert draw.return_value.text.call_args[0][0] == (48, 0) with patch( - "deckconnect.key.ImageDraw.Draw", + "knoepfe.key.ImageDraw.Draw", return_value=Mock(textsize=Mock(return_value=(0, 0))), ) as draw: renderer._render_text("text", "Text", size=12, color=None, valign="middle") assert draw.return_value.text.call_args[0][0] == (48, 48) with patch( - "deckconnect.key.ImageDraw.Draw", + "knoepfe.key.ImageDraw.Draw", return_value=Mock(textsize=Mock(return_value=(0, 0))), ) as draw: renderer._render_text("text", "Text", size=12, color=None, valign="bottom") @@ -52,7 +52,7 @@ def test_renderer_draw_text() -> None: def test_key_render() -> None: key = Key(MagicMock(), 0) - with patch.multiple("deckconnect.key", PILHelper=DEFAULT, Renderer=DEFAULT): + with patch.multiple("knoepfe.key", PILHelper=DEFAULT, Renderer=DEFAULT): with key.renderer(): pass diff --git a/tests/test_main.py b/tests/test_main.py index 944e241..dfb01b8 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3,36 +3,36 @@ from pytest import raises from StreamDeck.Transport.Transport import TransportError -from deckconnect.__main__ import connect_device, main, run +from knoepfe.__main__ import connect_device, main, run def test_main_success() -> None: - with patch("deckconnect.__main__.run") as run, patch("sys.argv", ["deckconnect"]): + with patch("knoepfe.__main__.run") as run, patch("sys.argv", ["knoepfe"]): main() assert run.called - with patch( - "deckconnect.__main__.run", side_effect=Exception("Error!") - ) as run, patch("sys.argv", ["deckconnect"]): + with patch("knoepfe.__main__.run", side_effect=Exception("Error!")) as run, patch( + "sys.argv", ["knoepfe"] + ): with raises(SystemExit): main() assert run.called - with patch( - "deckconnect.__main__.run", side_effect=Exception("Error!") - ) as run, patch("sys.argv", ["deckconnect", "--verbose"]): + with patch("knoepfe.__main__.run", side_effect=Exception("Error!")) as run, patch( + "sys.argv", ["knoepfe", "--verbose"] + ): with raises(Exception): main() assert run.called async def test_run() -> None: - with patch("deckconnect.__main__.process_config", side_effect=Exception("Error")): + with patch("knoepfe.__main__.process_config", side_effect=Exception("Error")): with raises(Exception): await run(None) with patch.multiple( - "deckconnect.__main__", + "knoepfe.__main__", process_config=Mock(return_value=({}, Mock(), [Mock()])), connect_device=AsyncMock(return_value=Mock()), DeckManager=Mock( @@ -45,8 +45,8 @@ async def test_run() -> None: async def test_connect_device() -> None: with patch( - "deckconnect.__main__.DeviceManager.enumerate", + "knoepfe.__main__.DeviceManager.enumerate", side_effect=([], [Mock(key_layout=Mock(return_value=(2, 2)))]), - ) as device_manager_enumerate, patch("deckconnect.__main__.sleep", AsyncMock()): + ) as device_manager_enumerate, patch("knoepfe.__main__.sleep", AsyncMock()): await connect_device() assert device_manager_enumerate.called diff --git a/tests/widgets/test_base.py b/tests/widgets/test_base.py index 77091d1..30b872c 100644 --- a/tests/widgets/test_base.py +++ b/tests/widgets/test_base.py @@ -3,8 +3,8 @@ from pytest import raises -from deckconnect.deck import SwitchDeckException -from deckconnect.widgets.base import Widget +from knoepfe.deck import SwitchDeckException +from knoepfe.widgets.base import Widget async def test_presses() -> None: @@ -15,7 +15,7 @@ async def test_presses() -> None: assert triggered.call_args[0][0] is False with patch.object(widget, "triggered") as triggered, patch( - "deckconnect.widgets.base.sleep", AsyncMock() + "knoepfe.widgets.base.sleep", AsyncMock() ): await widget.pressed() await sleep(0.1) diff --git a/tests/widgets/test_text.py b/tests/widgets/test_text.py index f964924..808a12c 100644 --- a/tests/widgets/test_text.py +++ b/tests/widgets/test_text.py @@ -2,7 +2,7 @@ from schema import Schema -from deckconnect.widgets import Text +from knoepfe.widgets import Text async def test_text_update() -> None: