diff --git a/server/settings.py b/server/settings.py index 1b9d991..52e6445 100644 --- a/server/settings.py +++ b/server/settings.py @@ -25,6 +25,7 @@ INSTALLED_APPS = [ "stt.external_links", "stt.filters", + "stt.signals", "newsroom.auth.saml", ] diff --git a/server/setup.cfg b/server/setup.cfg index 6e6c103..4a76eea 100644 --- a/server/setup.cfg +++ b/server/setup.cfg @@ -3,8 +3,8 @@ max-line-length = 120 exclude = env,venv,node_modules,build [tool:pytest] -testpaths = stt_tests -confcutdir = stt_tests +testpaths = tests +confcutdir = tests addopts = --tb=short [mypy] diff --git a/server/stt/signals.py b/server/stt/signals.py new file mode 100644 index 0000000..1e281fc --- /dev/null +++ b/server/stt/signals.py @@ -0,0 +1,10 @@ + +from newsroom.signals import publish_planning + + +def set_planning_all_day(app, item, **kwargs): + item["dates"].setdefault("all_day", True) + + +def init_app(app): + publish_planning.connect(set_planning_all_day) diff --git a/server/stt_tests/__init__.py b/server/tests/__init__.py similarity index 100% rename from server/stt_tests/__init__.py rename to server/tests/__init__.py diff --git a/server/stt_tests/conftest.py b/server/tests/conftest.py similarity index 100% rename from server/stt_tests/conftest.py rename to server/tests/conftest.py diff --git a/server/stt_tests/fixtures.py b/server/tests/fixtures.py similarity index 100% rename from server/stt_tests/fixtures.py rename to server/tests/fixtures.py diff --git a/server/stt_tests/stt/__init__.py b/server/tests/stt/__init__.py similarity index 100% rename from server/stt_tests/stt/__init__.py rename to server/tests/stt/__init__.py diff --git a/server/stt_tests/test_example.py b/server/tests/test_example.py similarity index 100% rename from server/stt_tests/test_example.py rename to server/tests/test_example.py diff --git a/server/tests/test_signals.py b/server/tests/test_signals.py new file mode 100644 index 0000000..f80007e --- /dev/null +++ b/server/tests/test_signals.py @@ -0,0 +1,9 @@ + +from stt.signals import publish_planning, set_planning_all_day + + +def test_publish_planning_signal(): + publish_planning.connect(set_planning_all_day) + item = {"dates": {"start": 1, "end": 1}} + publish_planning.send(None, item=item, foo=1) + assert item["dates"]["all_day"] is True diff --git a/server/stt_tests/stt/test_stt_filters.py b/server/tests/test_stt_filters.py similarity index 100% rename from server/stt_tests/stt/test_stt_filters.py rename to server/tests/test_stt_filters.py