Refactor the test for v2 queues and messages
Change-Id: I8f5cc7f7e0ceefa1e8b4341ccc211f647df86876
This commit is contained in:
parent
c792f9b7d9
commit
bc123ad738
@ -16,14 +16,15 @@
|
|||||||
import json
|
import json
|
||||||
import mock
|
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 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 http
|
||||||
from zaqarclient.transport import response
|
from zaqarclient.transport import response
|
||||||
|
|
||||||
|
|
||||||
class TestMessageIterator(msg.TestMessageIterator):
|
class TestMessageIterator(base.QueuesTestBase):
|
||||||
def test_no_next_iteration(self):
|
def test_no_next_iteration(self):
|
||||||
messages = {'links': [],
|
messages = {'links': [],
|
||||||
'messages': [{
|
'messages': [{
|
||||||
@ -102,7 +103,7 @@ class TestMessageIterator(msg.TestMessageIterator):
|
|||||||
self.assertEqual(len(iterated), 1)
|
self.assertEqual(len(iterated), 1)
|
||||||
|
|
||||||
|
|
||||||
class QueuesV2MessageHttpUnitTest(msg.QueuesV1MessageHttpUnitTest):
|
class QueuesV2MessageHttpUnitTest(test_message.QueuesV2MessageUnitTest):
|
||||||
|
|
||||||
transport_cls = http.HttpTransport
|
transport_cls = http.HttpTransport
|
||||||
url = 'http://127.0.0.1:8888/v2'
|
url = 'http://127.0.0.1:8888/v2'
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from tests.unit.queues.v1 import test_queues
|
from zaqarclient.tests.queues import queues
|
||||||
from zaqarclient.transport import http
|
from zaqarclient.transport import http
|
||||||
|
|
||||||
|
|
||||||
class QueuesV2QueueHttpUnitTest(test_queues.QueuesV1QueueHttpUnitTest):
|
class QueuesV2QueueHttpUnitTest(queues.QueuesV2QueueUnitTest):
|
||||||
|
|
||||||
transport_cls = http.HttpTransport
|
transport_cls = http.HttpTransport
|
||||||
url = 'http://127.0.0.1:8888/v2'
|
url = 'http://127.0.0.1:8888/v2'
|
||||||
|
@ -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
|
from zaqarclient.queues.v1 import message
|
||||||
|
|
||||||
|
|
||||||
class Message(message.Message):
|
class Message(message.Message):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def create_object(parent):
|
||||||
|
return lambda args: Message(parent, **args)
|
||||||
|
@ -59,3 +59,7 @@ class QueuesV1MessageUnitTest(base.QueuesTestBase):
|
|||||||
|
|
||||||
send_method.return_value = None
|
send_method.return_value = None
|
||||||
self.assertIsNone(msg.delete())
|
self.assertIsNone(msg.delete())
|
||||||
|
|
||||||
|
|
||||||
|
class QueuesV2MessageUnitTest(QueuesV1MessageUnitTest):
|
||||||
|
pass
|
||||||
|
@ -463,5 +463,9 @@ class QueuesV1_1QueueFunctionalTest(QueuesV1QueueFunctionalTest):
|
|||||||
self.assertEqual(1, len(list(remaining)))
|
self.assertEqual(1, len(list(remaining)))
|
||||||
|
|
||||||
|
|
||||||
|
class QueuesV2QueueUnitTest(QueuesV1_1QueueUnitTest):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class QueuesV2QueueFunctionalTest(QueuesV1_1QueueFunctionalTest):
|
class QueuesV2QueueFunctionalTest(QueuesV1_1QueueFunctionalTest):
|
||||||
pass
|
pass
|
||||||
|
@ -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())
|
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user