summaryrefslogtreecommitdiffstats
path: root/tests/unit/rpc
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2013-05-20 22:14:31 +0000
committerChris Behrens <cbehrens@codestud.com>2013-05-20 22:14:31 +0000
commitdf7ea8308363235afba503f8562341bd2e3dce4f (patch)
tree68fd667af50830e89a44de39db9dacfaa99eeafa /tests/unit/rpc
parent97bb81ddbcc47343c78e0a6efe724878fcb35ecb (diff)
downloadoslo-df7ea8308363235afba503f8562341bd2e3dce4f.tar.gz
oslo-df7ea8308363235afba503f8562341bd2e3dce4f.tar.xz
oslo-df7ea8308363235afba503f8562341bd2e3dce4f.zip
Allow RPC_API_NAMESPACE on RpcProxy objects
This allows one to subclass RpcProxy for use with a particular namespace without having to repeatedly pass the namespace into the make_namespaced_msg() method. This new RPC_API_NAMESPACE attribute will be used for the make_msg() call. It is defaulted to None to match previous behavior. Change-Id: Ied62df839cda0be6f9f9b060bbfc22e086f61be8
Diffstat (limited to 'tests/unit/rpc')
-rw-r--r--tests/unit/rpc/test_proxy.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unit/rpc/test_proxy.py b/tests/unit/rpc/test_proxy.py
index 63360ba..f05964b 100644
--- a/tests/unit/rpc/test_proxy.py
+++ b/tests/unit/rpc/test_proxy.py
@@ -158,8 +158,19 @@ class RpcProxyTestCase(utils.BaseTestCase):
'args': {'a': 1, 'b': 2}}
self.assertEqual(msg, expected)
- def test_make_msg(self):
- msg = proxy.RpcProxy.make_msg('test_method', a=1, b=2)
+ def test_make_msg_with_no_namespace(self):
+ proxy_obj = proxy.RpcProxy('fake', '1.0')
+ msg = proxy_obj.make_msg('test_method', a=1, b=2)
expected = {'method': 'test_method', 'namespace': None,
'args': {'a': 1, 'b': 2}}
self.assertEqual(msg, expected)
+
+ def test_make_msg_with_namespace(self):
+ class TestProxy(proxy.RpcProxy):
+ RPC_API_NAMESPACE = 'meow'
+
+ proxy_obj = TestProxy('fake', '1.0')
+ msg = proxy_obj.make_msg('test_method', a=1, b=2)
+ expected = {'method': 'test_method', 'namespace': 'meow',
+ 'args': {'a': 1, 'b': 2}}
+ self.assertEqual(msg, expected)