diff --git a/junebug/api.py b/junebug/api.py index 5b99cb3..455f0a1 100644 --- a/junebug/api.py +++ b/junebug/api.py @@ -278,7 +278,7 @@ def send_message(self, request, body, channel_id): @inlineCallbacks def get_message_status(self, request, channel_id, message_id): '''Retrieve the status of a message''' - data = yield self.get_channel_message_events( + data = yield self.get_message_events( request, channel_id, message_id) returnValue(response(request, 'message status', data)) @@ -584,7 +584,7 @@ def send_destination_message( router = yield Router.from_id(self, router_id) router.get_destination(destination_id) channel_id = yield router.router_worker.get_destination_channel( - destination_id, message_body=body) + destination_id, body) msg = yield self.send_messsage_on_channel(channel_id, body) @@ -600,19 +600,17 @@ def get_destination_message_status( router = yield Router.from_id(self, router_id) router.get_destination(destination_id) - channel_id = yield router.router_worker.get_destination_channel( - destination_id, message_id=message_id) - data = yield self.get_channel_message_events( - request, channel_id, message_id) + data = yield self.get_message_events( + request, destination_id, message_id) returnValue(response(request, 'message status', data)) @inlineCallbacks - def get_channel_message_events(self, request, channel_id, message_id): - events = yield self.outbounds.load_all_events(channel_id, message_id) + def get_message_events(self, request, location_id, message_id): + events = yield self.outbounds.load_all_events(location_id, message_id) events = sorted( - (api_from_event(channel_id, e) for e in events), + (api_from_event(location_id, e) for e in events), key=lambda e: e['timestamp']) last_event = events[-1] if events else None diff --git a/junebug/router/base.py b/junebug/router/base.py index 10413ed..4e544ad 100644 --- a/junebug/router/base.py +++ b/junebug/router/base.py @@ -356,12 +356,11 @@ def teardown_router(self): done here. May return a deferred. """ - def get_destination_channel( - self, destination_id, message_body=None, message_id=None): + def get_destination_channel(self, destination_id, message_body): """ - Gets the channel associated with the specified destination. Either - message_body or message_id will be supplied. Should be implemented by - router implementation. + Gets the channel associated with the specified destination. The + message_body will always be supplied. Should be implemented by router + implementation. """ def setup_connectors(self): diff --git a/junebug/router/from_address.py b/junebug/router/from_address.py index 1149651..4affaa3 100644 --- a/junebug/router/from_address.py +++ b/junebug/router/from_address.py @@ -136,8 +136,7 @@ def setup_router(self): self.consume_destination( destination['id'], self.handle_outbound_message) - def get_destination_channel( - self, destination_id, message_body=None, message_id=None): + def get_destination_channel(self, destination_id, message_body): config = self.get_static_config() return succeed(str(config.channel)) diff --git a/junebug/tests/helpers.py b/junebug/tests/helpers.py index 155a674..e0e5359 100644 --- a/junebug/tests/helpers.py +++ b/junebug/tests/helpers.py @@ -170,8 +170,7 @@ def teardown_router(self): def test_log(self, message='Test log'): self.log.msg(message, source=self) - def get_destination_channel( - self, destination_id, message_body=None, message_id=None): + def get_destination_channel(self, destination_id, message_body): config = self.get_static_config() for dest in config.destinations: diff --git a/junebug/tests/test_api.py b/junebug/tests/test_api.py index fd554ae..3fa2d32 100644 --- a/junebug/tests/test_api.py +++ b/junebug/tests/test_api.py @@ -2118,11 +2118,11 @@ def test_get_destination_message_status_one_event(self): event = TransportEvent( user_message_id='message-id', sent_message_id='message-id', event_type='nack', nack_reason='error error') - yield self.outbounds.store_event('channel-id', 'message-id', event) + yield self.outbounds.store_event(destination_id, 'message-id', event) resp = yield self.get( '/routers/{}/destinations/{}/messages/message-id'.format( router_id, destination_id)) - event_dict = api_from_event('channel-id', event) + event_dict = api_from_event(destination_id, event) event_dict['timestamp'] = str(event_dict['timestamp']) yield self.assert_response( resp, http.OK, 'message status', { @@ -2152,9 +2152,10 @@ def test_get_destination_message_status_multiple_events(self): event = TransportEvent( user_message_id='message-id', sent_message_id='message-id', event_type='nack', nack_reason='error error') - yield self.outbounds.store_event('channel-id', 'message-id', event) + yield self.outbounds.store_event( + destination_id, 'message-id', event) events.append(event) - event_dict = api_from_event('channel-id', event) + event_dict = api_from_event(destination_id, event) event_dict['timestamp'] = str(event_dict['timestamp']) event_dicts.append(event_dict) diff --git a/junebug/tests/test_from_address_router.py b/junebug/tests/test_from_address_router.py index c9e5c2d..016ffe0 100644 --- a/junebug/tests/test_from_address_router.py +++ b/junebug/tests/test_from_address_router.py @@ -141,10 +141,12 @@ def test_get_destination_channel(self): 'channel': '41e58f4a-2acc-442f-b3e5-3cf2b2f1cf14', }) - channel_id = yield router.get_destination_channel("test-destination1") + channel_id = yield router.get_destination_channel( + "test-destination1", {}) self.assertEqual(channel_id, '41e58f4a-2acc-442f-b3e5-3cf2b2f1cf14') - channel_id = yield router.get_destination_channel("test-destination2") + channel_id = yield router.get_destination_channel( + "test-destination2", {}) self.assertEqual(channel_id, '41e58f4a-2acc-442f-b3e5-3cf2b2f1cf14') @inlineCallbacks