Skip to content

Commit

Permalink
Merge 62fed43 into 2ccae39
Browse files Browse the repository at this point in the history
  • Loading branch information
oakbani committed Jan 23, 2020
2 parents 2ccae39 + 62fed43 commit 7183c1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions optimizely/event/event_processor.py
@@ -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
@@ -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
)

0 comments on commit 7183c1d

Please sign in to comment.