• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.create_request函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zaqar.tests.unit.transport.websocket.utils.create_request函数的典型用法代码示例。如果您正苦于以下问题:Python create_request函数的具体用法?Python create_request怎么用?Python create_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_bad_client_id

    def test_bad_client_id(self, text_id):
        action = consts.MESSAGE_POST
        body = {
            "queue_name": "kinder",
            "messages": [{"ttl": 60,
                          "body": ""}]
        }
        headers = {
            'Client-ID': text_id,
            'X-Project-ID': self.project_id
        }

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(400, resp['headers']['status'])

        action = consts.MESSAGE_GET
        body = {
            "queue_name": "kinder",
            "limit": 3,
            "echo": True
        }

        req = test_utils.create_request(action, body, headers)
        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(400, resp['headers']['status'])
开发者ID:openstack,项目名称:zaqar,代码行数:34,代码来源:test_messages.py


示例2: test_non_ascii_name

    def test_non_ascii_name(self):
        test_params = ((u'/queues/non-ascii-n\u0153me', 'utf-8'),
                       (u'/queues/non-ascii-n\xc4me', 'iso8859-1'))

        headers = {
            'Client-ID': uuidutils.generate_uuid(),
            'X-Project-ID': 'test-project' * 30
        }
        action = consts.QUEUE_CREATE
        body = {"queue_name": test_params[0]}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp.decode())
            self.assertEqual(400, resp['headers']['status'])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)

        body = {"queue_name": test_params[1]}
        req = test_utils.create_request(action, body, headers)

        self.protocol.onMessage(req, False)
开发者ID:openstack,项目名称:zaqar,代码行数:28,代码来源:test_queue_lifecycle.py


示例3: test_project_id_restriction

    def test_project_id_restriction(self):
        headers = {
            'Client-ID': uuidutils.generate_uuid(),
            'X-Project-ID': 'test-project' * 30
        }
        action = consts.QUEUE_CREATE
        body = {"queue_name": 'poptart'}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp.decode())
            self.assertEqual(400, resp['headers']['status'])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)

        headers['X-Project-ID'] = 'test-project'
        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp.decode())
            self.assertIn(resp['headers']['status'], [201, 204])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)
开发者ID:openstack,项目名称:zaqar,代码行数:30,代码来源:test_queue_lifecycle.py


示例4: test_post_optional_ttl

    def test_post_optional_ttl(self):
        messages = [{'body': 239},
                    {'body': {'key': 'value'}, 'ttl': 200}]

        action = consts.MESSAGE_POST
        body = {"queue_name": "kitkat",
                "messages": messages}
        req = test_utils.create_request(action, body, self.headers)

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(201, resp['headers']['status'])
        msg_id = resp['body']['message_ids'][0]

        action = consts.MESSAGE_GET
        body = {"queue_name": "kitkat", "message_id": msg_id}

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(200, resp['headers']['status'])
        self.assertEqual(self.default_message_ttl,
                         resp['body']['messages']['ttl'])
开发者ID:openstack,项目名称:zaqar,代码行数:29,代码来源:test_messages.py


示例5: test_project_id_restriction

    def test_project_id_restriction(self):
        headers = {
            'Client-ID': str(uuid.uuid4()),
            'X-Project-ID': 'test-project' * 30
        }
        action = "queue_create"
        body = {"queue_name": 'poptart'}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(resp['headers']['status'], 400)

        send_mock.side_effect = validator
        self.protocol.onMessage(req, False)

        headers['X-Project-ID'] = 'test-project'
        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(resp['headers']['status'], 201)

        send_mock.side_effect = validator
        self.protocol.onMessage(req, False)
开发者ID:wenchma,项目名称:zaqar,代码行数:30,代码来源:test_queue_lifecycle.py


示例6: test_bulk_delete

    def test_bulk_delete(self):
        resp = self._post_messages("nerds", repeat=5)
        msg_ids = resp['body']['message_ids']

        action = "message_delete_many"
        body = {"queue_name": "nerds",
                "message_ids": msg_ids}

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)

        action = "message_get"
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 400)

        # Safe to delete non-existing ones
        action = "message_delete_many"
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)

        # Even after the queue is gone
        action = "queue_delete"
        body = {"queue_name": "nerds"}
        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)

        action = "message_delete_many"
        body = {"queue_name": "nerds",
                "message_ids": msg_ids}
        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)
开发者ID:wenchma,项目名称:zaqar,代码行数:52,代码来源:test_messages.py


示例7: test_bulk_delete

    def test_bulk_delete(self):
        resp = self._post_messages("nerds", repeat=5)
        msg_ids = resp['body']['message_ids']

        action = consts.MESSAGE_DELETE_MANY
        body = {"queue_name": "nerds",
                "message_ids": msg_ids}

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])

        action = consts.MESSAGE_GET
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(400, resp['headers']['status'])

        # Safe to delete non-existing ones
        action = consts.MESSAGE_DELETE_MANY
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])

        # Even after the queue is gone
        action = consts.QUEUE_DELETE
        body = {"queue_name": "nerds"}
        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])

        action = consts.MESSAGE_DELETE_MANY
        body = {"queue_name": "nerds",
                "message_ids": msg_ids}
        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])
开发者ID:openstack,项目名称:zaqar,代码行数:52,代码来源:test_messages.py


示例8: test_no_metadata

    def test_no_metadata(self):
        headers = {
            'Client-ID': str(uuid.uuid4()),
            'X-Project-ID': 'test-project'
        }
        action = consts.QUEUE_CREATE
        body = {"queue_name": "fizbat"}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(201, resp['headers']['status'])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(204, resp['headers']['status'])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)
开发者ID:ollie314,项目名称:zaqar,代码行数:27,代码来源:test_queue_lifecycle.py


示例9: test_way_too_much_metadata

    def test_way_too_much_metadata(self):
        headers = {
            'Client-ID': uuidutils.generate_uuid(),
            'X-Project-ID': 'test-project'
        }
        action = consts.QUEUE_CREATE
        body = {"queue_name": "peppermint",
                "metadata": {"messages": {"ttl": 600},
                             "padding": "x"}
                }

        max_size = self.transport_cfg.max_queue_metadata
        body["metadata"]["padding"] = "x" * max_size * 5

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp.decode())
            self.assertEqual(400, resp['headers']['status'])

        sender.side_effect = validator
        self.protocol.onMessage(req, False)
开发者ID:openstack,项目名称:zaqar,代码行数:26,代码来源:test_queue_lifecycle.py


示例10: test_subscription_list

    def test_subscription_list(self):
        sub = self.boot.storage.subscription_controller.create(
            'kitkat', '', 600, {}, project=self.project_id)
        self.addCleanup(
            self.boot.storage.subscription_controller.delete, 'kitkat', sub,
            project=self.project_id)
        action = 'subscription_list'
        body = {'queue_name': 'kitkat'}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        response = {
            'body': {
                'subscriptions': [{
                    'subscriber': '',
                    'source': 'kitkat',
                    'options': {},
                    'id': str(sub),
                    'ttl': 600}]},
            'headers': {'status': 200},
            'request': {'action': 'subscription_list',
                        'body': {'queue_name': 'kitkat'},
                        'api': 'v2', 'headers': self.headers}}

        self.assertEqual(1, sender.call_count)
        self.assertEqual(response, json.loads(sender.call_args[0][0]))
开发者ID:wangxiyuan1,项目名称:zaqar,代码行数:31,代码来源:test_subscriptions.py


示例11: test_subscription_delete

    def test_subscription_delete(self):
        sub = self.boot.storage.subscription_controller.create(
            'kitkat', '', 600, {}, project=self.project_id)
        self.addCleanup(
            self.boot.storage.subscription_controller.delete, 'kitkat', sub,
            project=self.project_id)
        action = 'subscription_delete'
        body = {'queue_name': 'kitkat', 'subscription_id': str(sub)}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)
        data = list(
            next(
                self.boot.storage.subscription_controller.list(
                    'kitkat', self.project_id)))
        self.assertEqual([], data)

        response = {
            'body': 'Subscription %s removed.' % str(sub),
            'headers': {'status': 204},
            'request': {'action': 'subscription_delete',
                        'body': {'queue_name': 'kitkat',
                                 'subscription_id': str(sub)},
                        'api': 'v2', 'headers': self.headers}}
        self.assertEqual(1, sender.call_count)
        self.assertEqual(response, json.loads(sender.call_args[0][0]))
开发者ID:wangxiyuan1,项目名称:zaqar,代码行数:30,代码来源:test_subscriptions.py


示例12: test_list_returns_503_on_nopoolfound_exception

    def test_list_returns_503_on_nopoolfound_exception(self):
        headers = {
            'Client-ID': uuidutils.generate_uuid(),
            'X-Project-ID': 'test-project'
        }
        action = consts.QUEUE_LIST
        body = {}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp.decode())
            self.assertEqual(503, resp['headers']['status'])

        sender.side_effect = validator

        queue_controller = self.boot.storage.queue_controller

        with mock.patch.object(queue_controller, 'list') as mock_queue_list:

            def queue_generator():
                raise storage_errors.NoPoolFound()

            # This generator tries to be like queue controller list generator
            # in some ways.
            def fake_generator():
                yield queue_generator()
                yield {}
            mock_queue_list.return_value = fake_generator()
            self.protocol.onMessage(req, False)
开发者ID:openstack,项目名称:zaqar,代码行数:34,代码来源:test_queue_lifecycle.py


示例13: test_subscription_create_trust

    def test_subscription_create_trust(self, create_trust):
        create_trust.return_value = 'trust_id'
        action = 'subscription_create'
        body = {'queue_name': 'kitkat', 'ttl': 600,
                'subscriber': 'trust+http://example.com'}
        self.protocol._auth_env = {}
        self.protocol._auth_env['X-USER-ID'] = 'user-id'
        self.protocol._auth_env['X-ROLES'] = 'my-roles'

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        send_mock.start()

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)
        [subscriber] = list(
            next(
                self.boot.storage.subscription_controller.list(
                    'kitkat', self.project_id)))
        self.addCleanup(
            self.boot.storage.subscription_controller.delete, 'kitkat',
            subscriber['id'], project=self.project_id)
        self.assertEqual('trust+http://example.com',
                         subscriber['subscriber'])
        self.assertEqual({'trust_id': 'trust_id'}, subscriber['options'])

        self.assertEqual('user-id', create_trust.call_args[0][1])
        self.assertEqual(self.project_id, create_trust.call_args[0][2])
        self.assertEqual(['my-roles'], create_trust.call_args[0][3])
开发者ID:AvnishPal,项目名称:zaqar,代码行数:29,代码来源:test_subscriptions.py


示例14: test_subscription_get

    def test_subscription_get(self):
        sub = self.boot.storage.subscription_controller.create(
            'kitkat', '', 600, {}, project=self.project_id)
        self.addCleanup(
            self.boot.storage.subscription_controller.delete, 'kitkat', sub,
            project=self.project_id)
        action = 'subscription_get'
        body = {'queue_name': 'kitkat', 'subscription_id': str(sub)}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        expected_response_without_age = {
            'body': {'subscriber': '',
                     'source': 'kitkat',
                     'options': {},
                     'id': str(sub),
                     'ttl': 600},
            'headers': {'status': 200},
            'request': {'action': 'subscription_get',
                        'body': {'queue_name': 'kitkat',
                                 'subscription_id': str(sub)},
                        'api': 'v2', 'headers': self.headers}}

        self.assertEqual(1, sender.call_count)
        response = json.loads(sender.call_args[0][0])
        # Get and remove age from the actual response.
        actual_sub_age = response['body'].pop('age')
        self.assertLessEqual(0, actual_sub_age)
        self.assertEqual(expected_response_without_age, response)
开发者ID:AvnishPal,项目名称:zaqar,代码行数:34,代码来源:test_subscriptions.py


示例15: test_too_much_metadata

    def test_too_much_metadata(self):
        headers = {
            'Client-ID': str(uuid.uuid4()),
            'X-Project-ID': 'test-project'
        }
        action = "queue_create"
        body = {"queue_name": "buttertoffee",
                "metadata": {"messages": {"ttl": 600},
                             "padding": "x"}
                }

        max_size = self.transport_cfg.max_queue_metadata
        body["metadata"]["padding"] = "x" * max_size

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        send_mock.start()

        req = test_utils.create_request(action, body, headers)

        def validator(resp, isBinary):
            resp = json.loads(resp)
            self.assertEqual(resp['headers']['status'], 400)

        send_mock.side_effect = validator
        self.protocol.onMessage(req, False)
开发者ID:wenchma,项目名称:zaqar,代码行数:26,代码来源:test_queue_lifecycle.py


示例16: test_subscription_create_no_queue

    def test_subscription_create_no_queue(self):
        action = 'subscription_create'
        body = {'queue_name': 'shuffle', 'ttl': 600}

        send_mock = mock.patch.object(self.protocol, 'sendMessage')
        self.addCleanup(send_mock.stop)
        sender = send_mock.start()

        subscription_factory = factory.NotificationFactory(None)
        subscription_factory.set_subscription_url('http://localhost:1234/')
        self.protocol._handler.set_subscription_factory(subscription_factory)

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)

        [subscriber] = list(
            next(
                self.boot.storage.subscription_controller.list(
                    'shuffle', self.project_id)))
        self.addCleanup(
            self.boot.storage.subscription_controller.delete, 'shuffle',
            subscriber['id'], project=self.project_id)

        response = {
            'body': {'message': 'Subscription shuffle created.',
                     'subscription_id': subscriber['id']},
            'headers': {'status': 201},
            'request': {'action': 'subscription_create',
                        'body': {'queue_name': 'shuffle', 'ttl': 600},
                        'api': 'v2', 'headers': self.headers}}

        self.assertEqual(1, sender.call_count)
        self.assertEqual(response, json.loads(sender.call_args[0][0]))
开发者ID:AvnishPal,项目名称:zaqar,代码行数:33,代码来源:test_subscriptions.py


示例17: setUp

    def setUp(self):
        super(ClaimsBaseTest, self).setUp()
        self.protocol = self.transport.factory()
        self.defaults = self.api.get_defaults()

        self.project_id = '7e55e1a7e'
        self.headers = {
            'Client-ID': str(uuid.uuid4()),
            'X-Project-ID': self.project_id
        }

        action = "queue_create"
        body = {"queue_name": "skittle"}
        req = test_utils.create_request(action, body, self.headers)

        with mock.patch.object(self.protocol, 'sendMessage') as msg_mock:
            self.protocol.onMessage(req, False)
            resp = json.loads(msg_mock.call_args[0][0])
            self.assertEqual(201, resp['headers']['status'])

        action = "message_post"
        body = {"queue_name": "skittle",
                "messages": [
                    {'body': 239, 'ttl': 300},
                    {'body': {'key_1': 'value_1'}, 'ttl': 300},
                    {'body': [1, 3], 'ttl': 300},
                    {'body': 439, 'ttl': 300},
                    {'body': {'key_2': 'value_2'}, 'ttl': 300},
                    {'body': ['a', 'b'], 'ttl': 300},
                    {'body': 639, 'ttl': 300},
                    {'body': {'key_3': 'value_3'}, 'ttl': 300},
                    {'body': ["aa", "bb"], 'ttl': 300}]
                }

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(201, resp['headers']['status'])
开发者ID:AvnishPal,项目名称:zaqar,代码行数:43,代码来源:test_claims.py


示例18: test_bad_claim

    def test_bad_claim(self, doc):
        action = "claim_create"
        body = doc

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(400, resp['headers']['status'])

        action = "claim_update"
        body = doc

        req = test_utils.create_request(action, body, self.headers)
        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(400, resp['headers']['status'])
开发者ID:AvnishPal,项目名称:zaqar,代码行数:19,代码来源:test_claims.py


示例19: test_delete

    def test_delete(self):
        resp = self._post_messages("tofi")
        msg_id = resp['body']['message_ids'][0]

        action = consts.MESSAGE_GET
        body = {"queue_name": "tofi",
                "message_id": msg_id}

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(200, resp['headers']['status'])

        # Delete queue
        action = consts.MESSAGE_DELETE
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])

        # Get non existent queue
        action = consts.MESSAGE_GET
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(404, resp['headers']['status'])

        # Safe to delete non-existing ones
        action = consts.MESSAGE_DELETE
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0].decode())
        self.assertEqual(204, resp['headers']['status'])
开发者ID:openstack,项目名称:zaqar,代码行数:42,代码来源:test_messages.py


示例20: test_delete

    def test_delete(self):
        resp = self._post_messages("tofi")
        msg_id = resp['body']['message_ids'][0]

        action = "message_get"
        body = {"queue_name": "tofi",
                "message_id": msg_id}

        send_mock = mock.Mock()
        self.protocol.sendMessage = send_mock

        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 200)

        # Delete queue
        action = "message_delete"
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)

        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)

        # Get non existent queue
        action = "message_get"
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 404)

        # Safe to delete non-existing ones
        action = "message_delete"
        req = test_utils.create_request(action, body, self.headers)

        self.protocol.onMessage(req, False)
        resp = json.loads(send_mock.call_args[0][0])
        self.assertEqual(resp['headers']['status'], 204)
开发者ID:wenchma,项目名称:zaqar,代码行数:42,代码来源:test_messages.py



注:本文中的zaqar.tests.unit.transport.websocket.utils.create_request函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.to_json函数代码示例发布时间:2022-05-26
下一篇:
Python helpers.create_message_body_v1_1函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap