Skip to content

Commit

Permalink
test: test the "append to events settings" functionality
Browse files Browse the repository at this point in the history
and fix coverage
  • Loading branch information
pomegranited committed Jun 20, 2024
1 parent c5a89fa commit 5685b3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions event_routing_backends/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def plugin_settings(settings):
settings.EVENT_TRACKING_BACKENDS_ALLOWED_CALIPER_EVENTS
)

if not hasattr(settings, 'EVENT_TRACKING_BACKENDS') or not settings.EVENT_TRACKING_BACKENDS:
settings.EVENT_TRACKING_BACKENDS = {}
settings.EVENT_TRACKING_BACKENDS.update(event_tracking_backends_config(
settings,
settings.EVENT_TRACKING_BACKENDS_ALLOWED_XAPI_EVENTS,
Expand Down
16 changes: 15 additions & 1 deletion event_routing_backends/tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from django.conf import settings
from django.test import TestCase
from django.test import override_settings, TestCase

from event_routing_backends.settings import common as common_settings
from event_routing_backends.settings import devstack as devstack_settings
Expand Down Expand Up @@ -82,3 +82,17 @@ def test_production_settings(self):
self.assertTrue(settings.CALIPER_EVENT_LOGGING_ENABLED)
self.assertFalse(settings.XAPI_EVENTS_ENABLED)
self.assertTrue(settings.XAPI_EVENT_LOGGING_ENABLED)

@override_settings(
EVENT_TRACKING_BACKENDS_ALLOWED_XAPI_EVENTS=["my.event.1"],
EVENT_TRACKING_BACKENDS_ALLOWED_CALIPER_EVENTS=["my.event.2"],
EVENT_TRACKING_BACKENDS={},
)
def test_settings_append_events(self):
common_settings.plugin_settings(settings)

self.assertGreater(len(settings.EVENT_TRACKING_BACKENDS_ALLOWED_XAPI_EVENTS), 1)
self.assertIn("my.event.1", settings.EVENT_TRACKING_BACKENDS_ALLOWED_XAPI_EVENTS)

self.assertGreater(len(settings.EVENT_TRACKING_BACKENDS_ALLOWED_CALIPER_EVENTS), 1)
self.assertIn("my.event.2", settings.EVENT_TRACKING_BACKENDS_ALLOWED_CALIPER_EVENTS)

0 comments on commit 5685b3a

Please sign in to comment.