Skip to content

fix: Forwarding Event Processor defaults to default event dispatcher #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions optimizely/event/event_processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Optimizely
# Copyright 2019-2020 Optimizely
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -335,7 +335,7 @@ def __init__(self, event_dispatcher, logger=None, notification_center=None):
logger: Optional component which provides a log method to log messages. By default nothing would be logged.
notification_center: Optional instance of notification_center.NotificationCenter.
"""
self.event_dispatcher = event_dispatcher
self.event_dispatcher = event_dispatcher or default_event_dispatcher
self.logger = _logging.adapt_logger(logger or _logging.NoOpLogger())
self.notification_center = notification_center or _notification_center.NotificationCenter(self.logger)

Expand Down
10 changes: 9 additions & 1 deletion tests/test_event_processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019, Optimizely
# Copyright 2019-2020, Optimizely
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -24,6 +24,7 @@
from optimizely.event.event_factory import EventFactory
from optimizely.event.log_event import LogEvent
from optimizely.event.user_event_factory import UserEventFactory
from optimizely.event_dispatcher import EventDispatcher as default_event_dispatcher
from optimizely.helpers import enums
from optimizely.logger import SimpleLogger
from . import base
Expand Down Expand Up @@ -561,3 +562,10 @@ def on_log_event(log_event):
self.assertEqual(
1, len(self.optimizely.notification_center.notification_listeners[enums.NotificationTypes.LOG_EVENT]),
)

def test_event_processor_defaults_to_default_event_dispatcher(self):
event_processor = ForwardingEventProcessor(None)
self.assertEqual(
event_processor.event_dispatcher,
default_event_dispatcher
)