Esempio n. 1
0
 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)
Esempio n. 2
0
 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, {})
Esempio n. 3
0
 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"})
Esempio n. 4
0
 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])
Esempio n. 5
0
 def _get_discovery(self):
     return discovery.LocalDiscovery()
Esempio n. 6
0
        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
Esempio n. 7
0
 def test_get_local_publisher_negative(self):
     disc = discovery.LocalDiscovery()
     service_name = "some_service"
     self.assertRaises(exceptions.UnableToDiscover,
                       disc.get_local_publisher, service_name)