summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Royal <douglasroyal@gmail.com>2015-07-16 21:04:47 -0500
committerDoug Royal <douglasroyal@gmail.com>2015-07-19 21:46:37 -0500
commit9c06fa84a07c21807bb8c81a41e4e26e0c0e5105 (patch)
tree8da475eb478a340dd67a914e36a6931a0cfef807
parent9e4831c02233a1d50ca78877e28389f5c214c562 (diff)
downloadoslo-messaging-9c06fa84a07c21807bb8c81a41e4e26e0c0e5105.tar.gz
Move zmq tests into a subdirectory
There are no code changes in this commit. The zmq tests are being organized to match the development of the new zmq driver. Change-Id: Id79a2ade3874c56d8d5c3eca4689d49ba68d4418
-rw-r--r--oslo_messaging/tests/drivers/zmq/__init__.py0
-rw-r--r--oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py1
-rw-r--r--oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py (renamed from oslo_messaging/tests/drivers/test_impl_matchmaker.py)0
-rw-r--r--oslo_messaging/tests/drivers/zmq/matchmaker/test_matchmaker_redis.py (renamed from oslo_messaging/tests/drivers/test_matchmaker_redis.py)0
-rw-r--r--oslo_messaging/tests/drivers/zmq/test_impl_zmq.py (renamed from oslo_messaging/tests/drivers/test_impl_zmq.py)53
-rw-r--r--oslo_messaging/tests/drivers/zmq/test_zmq_serializer.py67
6 files changed, 68 insertions, 53 deletions
diff --git a/oslo_messaging/tests/drivers/zmq/__init__.py b/oslo_messaging/tests/drivers/zmq/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/oslo_messaging/tests/drivers/zmq/__init__.py
diff --git a/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py b/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/oslo_messaging/tests/drivers/zmq/matchmaker/__init__.py
@@ -0,0 +1 @@
+
diff --git a/oslo_messaging/tests/drivers/test_impl_matchmaker.py b/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py
index 8fa82c2..8fa82c2 100644
--- a/oslo_messaging/tests/drivers/test_impl_matchmaker.py
+++ b/oslo_messaging/tests/drivers/zmq/matchmaker/test_impl_matchmaker.py
diff --git a/oslo_messaging/tests/drivers/test_matchmaker_redis.py b/oslo_messaging/tests/drivers/zmq/matchmaker/test_matchmaker_redis.py
index f2498cd..f2498cd 100644
--- a/oslo_messaging/tests/drivers/test_matchmaker_redis.py
+++ b/oslo_messaging/tests/drivers/zmq/matchmaker/test_matchmaker_redis.py
diff --git a/oslo_messaging/tests/drivers/test_impl_zmq.py b/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py
index dd6df44..563483a 100644
--- a/oslo_messaging/tests/drivers/test_impl_zmq.py
+++ b/oslo_messaging/tests/drivers/zmq/test_impl_zmq.py
@@ -13,8 +13,6 @@
# under the License.
import logging
-import os
-import re
import socket
import threading
@@ -22,11 +20,9 @@ import fixtures
import testtools
import oslo_messaging
-from oslo_messaging._drivers.common import RPCException
from oslo_messaging._drivers import impl_zmq
from oslo_messaging._drivers.zmq_driver.broker.zmq_broker import ZmqBroker
from oslo_messaging._drivers.zmq_driver import zmq_async
-from oslo_messaging._drivers.zmq_driver import zmq_serializer
from oslo_messaging._i18n import _
from oslo_messaging.tests import utils as test_utils
@@ -248,52 +244,3 @@ class TestPoller(test_utils.BaseTestCase):
incoming, socket = reply_poller.poll(1)
self.assertIsNone(incoming)
self.assertIsNone(socket)
-
-
-class TestZmqSerializer(test_utils.BaseTestCase):
-
- def test_message_without_topic_raises_RPCException(self):
- # The topic is the 4th element of the message.
- msg_without_topic = ['only', 'three', 'parts']
-
- expected = "Message did not contain a topic: %s" % msg_without_topic
- with self.assertRaisesRegexp(RPCException, re.escape(expected)):
- zmq_serializer.get_topic_from_call_message(msg_without_topic)
-
- def test_invalid_topic_format_raises_RPCException(self):
- invalid_topic = "no dots to split on, so not index-able".encode('utf8')
- bad_message = ['', '', '', invalid_topic]
-
- expected_msg = "Topic was not formatted correctly: %s"
- expected_msg = expected_msg % invalid_topic.decode('utf8')
- with self.assertRaisesRegexp(RPCException, expected_msg):
- zmq_serializer.get_topic_from_call_message(bad_message)
-
- def test_py3_decodes_bytes_correctly(self):
- message = ['', '', '', b'topic.ipaddress']
-
- actual, _ = zmq_serializer.get_topic_from_call_message(message)
-
- self.assertEqual('topic', actual)
-
- def test_bad_characters_in_topic_raise_RPCException(self):
- # handle unexpected os path separators:
- unexpected_evil = '<'
- os.path.sep = unexpected_evil
-
- unexpected_alt_evil = '>'
- os.path.altsep = unexpected_alt_evil
-
- evil_chars = [unexpected_evil, unexpected_alt_evil, '\\', '/']
-
- for evil_char in evil_chars:
- evil_topic = '%s%s%s' % ('trust.me', evil_char, 'please')
- evil_topic = evil_topic.encode('utf8')
- evil_message = ['', '', '', evil_topic]
-
- expected_msg = "Topic contained dangerous characters: %s"
- expected_msg = expected_msg % evil_topic.decode('utf8')
- expected_msg = re.escape(expected_msg)
-
- with self.assertRaisesRegexp(RPCException, expected_msg):
- zmq_serializer.get_topic_from_call_message(evil_message)
diff --git a/oslo_messaging/tests/drivers/zmq/test_zmq_serializer.py b/oslo_messaging/tests/drivers/zmq/test_zmq_serializer.py
new file mode 100644
index 0000000..48f5273
--- /dev/null
+++ b/oslo_messaging/tests/drivers/zmq/test_zmq_serializer.py
@@ -0,0 +1,67 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import os
+import re
+
+from oslo_messaging._drivers.common import RPCException
+from oslo_messaging._drivers.zmq_driver import zmq_serializer
+from oslo_messaging.tests import utils as test_utils
+
+
+class TestZmqSerializer(test_utils.BaseTestCase):
+
+ def test_message_without_topic_raises_RPCException(self):
+ # The topic is the 4th element of the message.
+ msg_without_topic = ['only', 'three', 'parts']
+
+ expected = "Message did not contain a topic: %s" % msg_without_topic
+ with self.assertRaisesRegexp(RPCException, re.escape(expected)):
+ zmq_serializer.get_topic_from_call_message(msg_without_topic)
+
+ def test_invalid_topic_format_raises_RPCException(self):
+ invalid_topic = "no dots to split on, so not index-able".encode('utf8')
+ bad_message = ['', '', '', invalid_topic]
+
+ expected_msg = "Topic was not formatted correctly: %s"
+ expected_msg = expected_msg % invalid_topic.decode('utf8')
+ with self.assertRaisesRegexp(RPCException, expected_msg):
+ zmq_serializer.get_topic_from_call_message(bad_message)
+
+ def test_py3_decodes_bytes_correctly(self):
+ message = ['', '', '', b'topic.ipaddress']
+
+ actual, _ = zmq_serializer.get_topic_from_call_message(message)
+
+ self.assertEqual('topic', actual)
+
+ def test_bad_characters_in_topic_raise_RPCException(self):
+ # handle unexpected os path separators:
+ unexpected_evil = '<'
+ os.path.sep = unexpected_evil
+
+ unexpected_alt_evil = '>'
+ os.path.altsep = unexpected_alt_evil
+
+ evil_chars = [unexpected_evil, unexpected_alt_evil, '\\', '/']
+
+ for evil_char in evil_chars:
+ evil_topic = '%s%s%s' % ('trust.me', evil_char, 'please')
+ evil_topic = evil_topic.encode('utf8')
+ evil_message = ['', '', '', evil_topic]
+
+ expected_msg = "Topic contained dangerous characters: %s"
+ expected_msg = expected_msg % evil_topic.decode('utf8')
+ expected_msg = re.escape(expected_msg)
+
+ with self.assertRaisesRegexp(RPCException, expected_msg):
+ zmq_serializer.get_topic_from_call_message(evil_message)