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 dc3a0f2
Show file tree
Hide file tree
Showing 2 changed files with 16 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
15 changes: 14 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 TestCase, override_settings

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,16 @@ 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"],
)
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 dc3a0f2

Please sign in to comment.