From d0c96b853d983e4b6afdf0401bf26b3b93dcb841 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 14 Jul 2025 02:31:47 +0100 Subject: [PATCH] add text unit tests --- tests/conftest.py | 7 +++++++ tests/test_text.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/test_text.py diff --git a/tests/conftest.py b/tests/conftest.py index 31709ae..7bfe26b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -71,6 +71,13 @@ def pytest_sessionstart(session): }, sceneItemEnabled=True, ) + session.obsws.create_input( + sceneName='pytest_scene', + inputName='pytest_text_input', + inputKind='text_gdiplus_v3', + inputSettings={'text': 'Hello, OBS!'}, + sceneItemEnabled=True, + ) resp = session.obsws.get_scene_item_list('pytest_scene') for item in resp.scene_items: if item['sourceName'] == 'pytest_input_2': diff --git a/tests/test_text.py b/tests/test_text.py new file mode 100644 index 0000000..4d060f3 --- /dev/null +++ b/tests/test_text.py @@ -0,0 +1,18 @@ +"""Unit tests for the text command in the OBS WebSocket CLI.""" + +from typer.testing import CliRunner + +from obsws_cli.app import app + +runner = CliRunner(mix_stderr=False) + + +def test_text_update(): + """Test the text update command.""" + result = runner.invoke(app, ['text', 'current', 'pytest_text_input']) + assert result.exit_code == 0 + assert 'Current text for input pytest_text_input: Hello, OBS!' in result.stdout + + result = runner.invoke(app, ['text', 'update', 'pytest_text_input', 'New Text']) + assert result.exit_code == 0 + assert 'Text for input pytest_text_input updated to: New Text' in result.stdout