diff --git a/tests/unit/queues/v2/test_message.py b/tests/unit/queues/v2/test_message.py index 6cef88f0..fc22d40b 100644 --- a/tests/unit/queues/v2/test_message.py +++ b/tests/unit/queues/v2/test_message.py @@ -16,14 +16,15 @@ import json import mock -from tests.unit.queues.v1 import test_message as msg from zaqarclient.queues.v1 import iterator as iterate -from zaqarclient.queues.v1 import message +from zaqarclient.queues.v2 import message +from zaqarclient.tests.queues import base +from zaqarclient.tests.queues import messages as test_message from zaqarclient.transport import http from zaqarclient.transport import response -class TestMessageIterator(msg.TestMessageIterator): +class TestMessageIterator(base.QueuesTestBase): def test_no_next_iteration(self): messages = {'links': [], 'messages': [{ @@ -102,7 +103,7 @@ class TestMessageIterator(msg.TestMessageIterator): self.assertEqual(len(iterated), 1) -class QueuesV2MessageHttpUnitTest(msg.QueuesV1MessageHttpUnitTest): +class QueuesV2MessageHttpUnitTest(test_message.QueuesV2MessageUnitTest): transport_cls = http.HttpTransport url = 'http://127.0.0.1:8888/v2' diff --git a/tests/unit/queues/v2/test_queues.py b/tests/unit/queues/v2/test_queues.py index 88103b86..aad7d560 100644 --- a/tests/unit/queues/v2/test_queues.py +++ b/tests/unit/queues/v2/test_queues.py @@ -13,11 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tests.unit.queues.v1 import test_queues +from zaqarclient.tests.queues import queues from zaqarclient.transport import http -class QueuesV2QueueHttpUnitTest(test_queues.QueuesV1QueueHttpUnitTest): +class QueuesV2QueueHttpUnitTest(queues.QueuesV2QueueUnitTest): transport_cls = http.HttpTransport url = 'http://127.0.0.1:8888/v2' diff --git a/zaqarclient/queues/v2/message.py b/zaqarclient/queues/v2/message.py index 41a8a687..ecf95a6f 100644 --- a/zaqarclient/queues/v2/message.py +++ b/zaqarclient/queues/v2/message.py @@ -1,5 +1,24 @@ +# Copyright (c) 2013 Red Hat, Inc. +# +# 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. + from zaqarclient.queues.v1 import message class Message(message.Message): pass + + +def create_object(parent): + return lambda args: Message(parent, **args) diff --git a/zaqarclient/tests/queues/messages.py b/zaqarclient/tests/queues/messages.py index 0b5cc41d..b91d1e5e 100644 --- a/zaqarclient/tests/queues/messages.py +++ b/zaqarclient/tests/queues/messages.py @@ -59,3 +59,7 @@ class QueuesV1MessageUnitTest(base.QueuesTestBase): send_method.return_value = None self.assertIsNone(msg.delete()) + + +class QueuesV2MessageUnitTest(QueuesV1MessageUnitTest): + pass diff --git a/zaqarclient/tests/queues/queues.py b/zaqarclient/tests/queues/queues.py index e23e93a5..4c05315d 100644 --- a/zaqarclient/tests/queues/queues.py +++ b/zaqarclient/tests/queues/queues.py @@ -463,5 +463,9 @@ class QueuesV1_1QueueFunctionalTest(QueuesV1QueueFunctionalTest): self.assertEqual(1, len(list(remaining))) +class QueuesV2QueueUnitTest(QueuesV1_1QueueUnitTest): + pass + + class QueuesV2QueueFunctionalTest(QueuesV1_1QueueFunctionalTest): pass diff --git a/zaqarclient/tests/queues/v2/__init__.py b/zaqarclient/tests/queues/v2/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/zaqarclient/tests/queues/v2/messages.py b/zaqarclient/tests/queues/v2/messages.py deleted file mode 100644 index 26d30a76..00000000 --- a/zaqarclient/tests/queues/v2/messages.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2013 Red Hat, Inc. -# -# 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 json -import mock - -from zaqarclient.tests.queues.v1 import messages -from zaqarclient.transport import response - - -class QueuesV2MessageUnitTest(messages.QueuesV1MessageUnitTest): - - def test_message_delete(self): - returned = { - 'href': '/v2/queues/fizbit/messages/50b68a50d6f5b8c8a7c62b01', - 'ttl': 800, - 'age': 790, - 'body': {'event': 'ActivateAccount', 'mode': 'active'} - } - - with mock.patch.object(self.transport, 'send', - autospec=True) as send_method: - - resp = response.Response(None, json.dumps(returned)) - send_method.return_value = resp - - msg = self.queue.message('50b68a50d6f5b8c8a7c62b01') - - send_method.return_value = None - self.assertIsNone(msg.delete()) - - def test_message_delete_with_claim(self): - returned = { - 'href': '/v2/queues/fizbit/messages/50b68a50d6?claim_id=5388b5dd0', - 'ttl': 800, - 'age': 790, - 'body': {'event': 'ActivateAccount', 'mode': 'active'} - } - - with mock.patch.object(self.transport, 'send', - autospec=True) as send_method: - - resp = response.Response(None, json.dumps(returned)) - send_method.return_value = resp - - msg = self.queue.message('50b68a50d6') - - send_method.return_value = None - self.assertIsNone(msg.delete()) diff --git a/zaqarclient/tests/queues/v2/queues.py b/zaqarclient/tests/queues/v2/queues.py deleted file mode 100644 index 45f9592e..00000000 --- a/zaqarclient/tests/queues/v2/queues.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2013 Red Hat, Inc. -# -# 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. - -from zaqarclient.tests.queues.v1 import queues - - -class QueuesV2QueueUnitTest(queues.QueuesV1_1QueueUnitTest): - pass - - -class QueuesV2QueueFunctionalTest(queues.QueuesV1_1QueueFunctionalTest): - pass