def test_get_local_publisher_positive(self): disc = discovery.LocalDiscovery() service_name = "some_service" exchange_name = "some_exchange" disc.register_local_publisher(service_name, exchange_name) res = disc.get_local_publisher(service_name) self.assertEqual(res, exchange_name)
def test_unregister_local_publisher(self): disc = discovery.LocalDiscovery() service_name = "some_service" exchange_name = "some_exchange" disc.register_local_publisher(service_name, exchange_name) disc.unregister_local_publisher(service_name) self.assertDictEqual(disc._local_publisher_registry, {})
def test_register_remote_publisher(self): disc = discovery.LocalDiscovery() service_name = "some_service" exchange_name = "some_exchange" disc.register_remote_publisher(service_name, exchange_name) self.assertDictEqual(disc._remote_publisher_registry, {"some_service": "some_exchange"})
def test_get_all_exchanges(self): disc = discovery.LocalDiscovery() service_name = "some_service" exchange_name = "some_exchange" disc.register_remote_service(service_name, exchange_name) disc.register_remote_publisher(service_name, exchange_name) disc.register_local_publisher(service_name, exchange_name) res = disc.get_all_exchanges() self.assertListEqual(res["remote"], [exchange_name]) self.assertListEqual(res["remote_publisher"], [exchange_name]) self.assertListEqual(res["local_publisher"], [exchange_name])
def _get_discovery(self): return discovery.LocalDiscovery()
print error.context print error.headers print error.payload print "----------------------------" @dispatcher.subscription_method(service="test_hello", method="hello") def hello_subscription(self, notification, proxy, param): print "---- notification to chuck_norris ------" print notification.context print notification.headers print param print "---------------------------" proxy.test_hello.hello_with_error(param="strike-456").call() disc = discovery.LocalDiscovery() # FOR RPC # ------- # register remote service's exchanges to send there requests (RPC calls) disc.register_remote_service("test_hello", "test_exchange") # FOR SUBSCRIBE # ------------- # register remote notification exchange to bind to it and get notifications # In this example service 'test_subscribe' gets notifications to it's queue # from 'test_notification_exchange' which is the publication exchange of # service 'test_hello' disc.register_remote_publisher("test_hello", "test_notification_exchange") # FOR RPC AND SUBSCRIBE
def test_get_local_publisher_negative(self): disc = discovery.LocalDiscovery() service_name = "some_service" self.assertRaises(exceptions.UnableToDiscover, disc.get_local_publisher, service_name)