当前位置: 首页>>代码示例>>Python>>正文


Python tests.expect函数代码示例

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


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

示例1: test_illformed_id

    def test_illformed_id(self):
        # any ill-formed IDs should be regarded as non-existing ones.

        self.controller.delete(self.queue_name, "illformed", project=self.project)

        with testing.expect(errors.DoesNotExist):
            self.controller.get(self.queue_name, "illformed", project=self.project)

        with testing.expect(errors.DoesNotExist):
            self.controller.update(self.queue_name, "illformed", {"ttl": 40}, project=self.project)
开发者ID:kangliqiang,项目名称:marconi,代码行数:10,代码来源:base.py

示例2: test_expired_claim

    def test_expired_claim(self):
        meta = {"ttl": 0, "grace": 60}

        claim_id, messages = self.controller.create(self.queue_name, meta, project=self.project)

        with testing.expect(storage.errors.DoesNotExist):
            self.controller.get(self.queue_name, claim_id, project=self.project)

        with testing.expect(storage.errors.DoesNotExist):
            self.controller.update(self.queue_name, claim_id, meta, project=self.project)
开发者ID:kangliqiang,项目名称:marconi,代码行数:10,代码来源:base.py

示例3: test_expired_claim

    def test_expired_claim(self):
        meta = {'ttl': 0, 'grace': 60}

        claim_id, messages = self.controller.create(self.queue_name, meta,
                                                    project=self.project)

        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.get(self.queue_name, claim_id,
                                project=self.project)

        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.update(self.queue_name, claim_id,
                                   meta, project=self.project)
开发者ID:chadlung,项目名称:marconi,代码行数:13,代码来源:base.py

示例4: test_claim_effects

    def test_claim_effects(self):
        client_uuid = uuid.uuid4()

        _insert_fixtures(self.controller, self.queue_name, project=self.project, client_uuid=client_uuid, num=12)

        def list_messages(include_claimed=None):
            kwargs = {"project": self.project, "client_uuid": client_uuid, "echo": True}

            # Properly test default value
            if include_claimed is not None:
                kwargs["include_claimed"] = include_claimed

            interaction = self.controller.list(self.queue_name, **kwargs)

            messages = next(interaction)
            return [msg["id"] for msg in messages]

        messages_before = list_messages(True)

        meta = {"ttl": 70, "grace": 60}
        another_cid, _ = self.claim_controller.create(self.queue_name, meta, project=self.project)

        messages_after = list_messages(True)
        self.assertEqual(messages_before, messages_after)

        messages_excluding_claimed = list_messages()
        self.assertNotEqual(messages_before, messages_excluding_claimed)
        self.assertEqual(2, len(messages_excluding_claimed))

        cid, msgs = self.claim_controller.create(self.queue_name, meta, project=self.project)
        [msg1, msg2] = msgs

        # A wrong claim does not ensure the message deletion
        with testing.expect(storage.errors.NotPermitted):
            self.controller.delete(self.queue_name, msg1["id"], project=self.project, claim=another_cid)

        # Make sure a message can be deleted with a claim
        self.controller.delete(self.queue_name, msg1["id"], project=self.project, claim=cid)

        with testing.expect(storage.errors.DoesNotExist):
            self.controller.get(self.queue_name, msg1["id"], project=self.project)

        # Make sure such a deletion is idempotent
        self.controller.delete(self.queue_name, msg1["id"], project=self.project, claim=cid)

        # A non-existing claim does not ensure the message deletion
        self.claim_controller.delete(self.queue_name, cid, project=self.project)

        with testing.expect(storage.errors.NotPermitted):
            self.controller.delete(self.queue_name, msg2["id"], project=self.project, claim=cid)
开发者ID:kangliqiang,项目名称:marconi,代码行数:50,代码来源:base.py

示例5: test_message_lifecycle

    def test_message_lifecycle(self):
        queue_name = self.queue_name

        messages = [
            {
                'ttl': 60,
                'body': {
                    'event': 'BackupStarted',
                    'backupId': 'c378813c-3f0b-11e2-ad92-7823d2b0f3ce'
                }
            },
        ]

        # Test Message Creation
        created = list(self.controller.post(queue_name, messages,
                                            project=self.project,
                                            client_uuid=uuid.uuid4()))
        self.assertEqual(len(created), 1)

        # Test Message Get
        self.controller.get(queue_name, created[0], project=self.project)

        # Test Message Deletion
        self.controller.delete(queue_name, created[0], project=self.project)

        # Test does not exist
        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.get(queue_name, created[0], project=self.project)
开发者ID:chadlung,项目名称:marconi,代码行数:28,代码来源:base.py

示例6: test_message_lifecycle

    def test_message_lifecycle(self):
        queue_name = self.queue_name

        message = {
            'ttl': 60,
            'body': {
                'event': 'BackupStarted',
                'backupId': 'c378813c-3f0b-11e2-ad92-7823d2b0f3ce'
            }
        }

        # Test Message Creation
        created = list(self.controller.post(queue_name, [message],
                                            project=self.project,
                                            client_uuid=uuid.uuid4()))
        self.assertEqual(len(created), 1)
        message_id = created[0]

        # Test Message Get
        message_out = self.controller.get(queue_name, message_id,
                                          project=self.project)
        self.assertEqual(set(message_out), set(('id', 'body', 'ttl', 'age')))
        self.assertEqual(message_out['id'], message_id)
        self.assertEqual(message_out['body'], message['body'])
        self.assertEqual(message_out['ttl'], message['ttl'])

        # Test Message Deletion
        self.controller.delete(queue_name, message_id, project=self.project)

        # Test does not exist
        with testing.expect(storage.errors.DoesNotExist):
            self.controller.get(queue_name, message_id, project=self.project)
开发者ID:TheSriram,项目名称:marconi-1,代码行数:32,代码来源:base.py

示例7: test_illformed_id

    def test_illformed_id(self):
        # any ill-formed IDs should be regarded as non-existing ones.

        self.controller.delete(self.queue_name,
                               'illformed',
                               project=self.project)

        with testing.expect(exceptions.DoesNotExist):
            self.controller.get(self.queue_name,
                                'illformed',
                                project=self.project)

        with testing.expect(exceptions.DoesNotExist):
            self.controller.update(self.queue_name,
                                   'illformed',
                                   {'ttl': 40},
                                   project=self.project)
开发者ID:chadlung,项目名称:marconi,代码行数:17,代码来源:base.py

示例8: test_bad_id

    def test_bad_id(self):
        # NOTE(cpp-cabrera): A malformed ID should result in an empty
        # query. Raising an exception for validating IDs makes the
        # implementation more verbose instead of taking advantage of
        # the Maybe/Optional protocol, particularly when dealing with
        # bulk operations.
        bad_message_id = "xyz"
        self.controller.delete(self.queue_name, bad_message_id, project=self.project)

        with testing.expect(errors.MessageDoesNotExist):
            self.controller.get(self.queue_name, bad_message_id, project=self.project)
开发者ID:kangliqiang,项目名称:marconi,代码行数:11,代码来源:base.py

示例9: test_expired_message

    def test_expired_message(self):
        messages = [{'body': 3.14, 'ttl': 0}]

        [msgid] = self.controller.post(self.queue_name, messages,
                                       project=self.project,
                                       client_uuid='my_uuid')

        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.get(self.queue_name, msgid,
                                project=self.project)

        countof = self.queue_controller.stats(self.queue_name,
                                              project=self.project)
        self.assertEquals(countof['messages']['free'], 0)
开发者ID:pombredanne,项目名称:marconi,代码行数:14,代码来源:base.py

示例10: test_multi_ids

    def test_multi_ids(self):
        messages_in = [{"ttl": 120, "body": 0}, {"ttl": 240, "body": 1}]
        ids = self.controller.post(self.queue_name, messages_in, project=self.project, client_uuid=uuid.uuid4())

        messages_out = self.controller.bulk_get(self.queue_name, ids, project=self.project)

        for idx, message in enumerate(messages_out):
            self.assertEqual(message["body"], idx)

        self.controller.bulk_delete(self.queue_name, ids, project=self.project)

        with testing.expect(StopIteration):
            result = self.controller.bulk_get(self.queue_name, ids, project=self.project)
            next(result)
开发者ID:kangliqiang,项目名称:marconi,代码行数:14,代码来源:base.py

示例11: test_expired_messages

    def test_expired_messages(self):
        messages = [{"body": 3.14, "ttl": 0}]
        client_uuid = uuid.uuid4()

        [msgid] = self.controller.post(self.queue_name, messages, project=self.project, client_uuid=client_uuid)

        [msgid] = self.controller.post(self.queue_name, messages, project=self.project, client_uuid=client_uuid)

        time.sleep(self.gc_interval)

        with testing.expect(storage.errors.DoesNotExist):
            self.controller.get(self.queue_name, msgid, project=self.project)

        stats = self.queue_controller.stats(self.queue_name, project=self.project)

        self.assertEqual(stats["messages"]["free"], 0)
开发者ID:kangliqiang,项目名称:marconi,代码行数:16,代码来源:base.py

示例12: test_message_lifecycle

    def test_message_lifecycle(self):
        queue_name = self.queue_name

        messages = [{"ttl": 60, "body": {"event": "BackupStarted", "backupId": "c378813c-3f0b-11e2-ad92-7823d2b0f3ce"}}]

        # Test Message Creation
        created = list(self.controller.post(queue_name, messages, project=self.project, client_uuid=uuid.uuid4()))
        self.assertEqual(len(created), 1)

        # Test Message Get
        self.controller.get(queue_name, created[0], project=self.project)

        # Test Message Deletion
        self.controller.delete(queue_name, created[0], project=self.project)

        # Test does not exist
        with testing.expect(storage.errors.DoesNotExist):
            self.controller.get(queue_name, created[0], project=self.project)
开发者ID:kangliqiang,项目名称:marconi,代码行数:18,代码来源:base.py

示例13: test_multi_ids

    def test_multi_ids(self):
        messages_in = [{'ttl': 120, 'body': 0}, {'ttl': 240, 'body': 1}]
        ids = self.controller.post(self.queue_name, messages_in,
                                   project=self.project,
                                   client_uuid='my_uuid')

        messages_out = self.controller.bulk_get(self.queue_name, ids,
                                                project=self.project)

        for idx, message in enumerate(messages_out):
            self.assertEquals(message['body'], idx)

        self.controller.bulk_delete(self.queue_name, ids,
                                    project=self.project)

        with testing.expect(StopIteration):
            result = self.controller.bulk_get(self.queue_name, ids,
                                              project=self.project)
            next(result)
开发者ID:pombredanne,项目名称:marconi,代码行数:19,代码来源:base.py

示例14: test_expired_messages

    def test_expired_messages(self):
        messages = [{'body': 3.14, 'ttl': 0}]
        client_uuid = uuid.uuid4()

        [msgid] = self.controller.post(self.queue_name, messages,
                                       project=self.project,
                                       client_uuid=client_uuid)

        [msgid] = self.controller.post(self.queue_name, messages,
                                       project=self.project,
                                       client_uuid=client_uuid)

        time.sleep(self.gc_interval)

        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.get(self.queue_name, msgid,
                                project=self.project)

        stats = self.queue_controller.stats(self.queue_name,
                                            project=self.project)

        self.assertEqual(stats['messages']['free'], 0)
开发者ID:chadlung,项目名称:marconi,代码行数:22,代码来源:base.py

示例15: test_claim_effects

    def test_claim_effects(self):
        _insert_fixtures(self.controller, self.queue_name,
                         project=self.project, client_uuid='my_uuid', num=12)

        def list_messages(include_claimed=None):
            kwargs = {
                'project': self.project,
                'client_uuid': 'my_uuid',
                'echo': True,
            }

            # Properly test default value
            if include_claimed is not None:
                kwargs['include_claimed'] = include_claimed

            interaction = self.controller.list(self.queue_name, **kwargs)

            messages = next(interaction)
            return [msg['id'] for msg in messages]

        messages_before = list_messages(True)

        meta = {'ttl': 70, 'grace': 60}
        another_cid, _ = self.claim_controller.create(self.queue_name, meta,
                                                      project=self.project)

        messages_after = list_messages(True)
        self.assertEqual(messages_before, messages_after)

        messages_excluding_claimed = list_messages()
        self.assertNotEqual(messages_before, messages_excluding_claimed)
        self.assertEqual(2, len(messages_excluding_claimed))

        cid, msgs = self.claim_controller.create(self.queue_name, meta,
                                                 project=self.project)
        [msg1, msg2] = msgs

        # A wrong claim does not ensure the message deletion
        with testing.expect(storage.exceptions.NotPermitted):
            self.controller.delete(self.queue_name, msg1['id'],
                                   project=self.project,
                                   claim=another_cid)

        # Make sure a message can be deleted with a claim
        self.controller.delete(self.queue_name, msg1['id'],
                               project=self.project,
                               claim=cid)

        with testing.expect(storage.exceptions.DoesNotExist):
            self.controller.get(self.queue_name, msg1['id'],
                                project=self.project)

        # Make sure such a deletion is idempotent
        self.controller.delete(self.queue_name, msg1['id'],
                               project=self.project,
                               claim=cid)

        # A non-existing claim does not ensure the message deletion
        self.claim_controller.delete(self.queue_name, cid,
                                     project=self.project)

        with testing.expect(storage.exceptions.NotPermitted):
            self.controller.delete(self.queue_name, msg2['id'],
                                   project=self.project,
                                   claim=cid)
开发者ID:pombredanne,项目名称:marconi,代码行数:65,代码来源:base.py


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