diff --git a/eventtracking/backends/event_bus.py b/eventtracking/backends/event_bus.py index 8315f91..ca42988 100644 --- a/eventtracking/backends/event_bus.py +++ b/eventtracking/backends/event_bus.py @@ -1,11 +1,11 @@ """Event tracker backend that emits events to the event-bus.""" import json import logging +from datetime import datetime from openedx_events.analytics.data import TrackingLogData from openedx_events.analytics.signals import TRACKING_EVENT_EMITTED from openedx_events.event_bus import get_producer -from datetime import datetime from eventtracking.backends.routing import RoutingBackend from eventtracking.config import SEND_TRACKING_EVENT_EMITTED_SIGNAL @@ -43,9 +43,7 @@ def send(self, event): metadata = TRACKING_EVENT_EMITTED.generate_signal_metadata() - logger.info( - f"Sending tracking lof {tracking_log.name} to the event bus." - ) + logger.info(f"Sending tracking lof {tracking_log.name} to the event bus.") get_producer().send( signal=TRACKING_EVENT_EMITTED, topic="analytics", diff --git a/eventtracking/backends/tests/test_event_bus.py b/eventtracking/backends/tests/test_event_bus.py index 83bb6f5..c16a7ab 100644 --- a/eventtracking/backends/tests/test_event_bus.py +++ b/eventtracking/backends/tests/test_event_bus.py @@ -2,6 +2,7 @@ Test the async routing backend. """ import json +from datetime import datetime from unittest import TestCase from unittest.mock import Mock, patch, sentinel @@ -51,7 +52,9 @@ def test_successful_send_event(self, mock_get_producer): "event_data": { "tracking_log": TrackingLogData( name=self.sample_event["name"], - timestamp=self.sample_event["timestamp"], + timestamp=datetime.strptime( + self.sample_event["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z" + ), data=json.dumps(self.sample_event["data"]), context=json.dumps(self.sample_event["context"]), )