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


Python LoggedAction.of_type方法代码示例

本文整理汇总了Python中eliot.testing.LoggedAction.of_type方法的典型用法代码示例。如果您正苦于以下问题:Python LoggedAction.of_type方法的具体用法?Python LoggedAction.of_type怎么用?Python LoggedAction.of_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eliot.testing.LoggedAction的用法示例。


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

示例1: test_boto_ec2response_error

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def test_boto_ec2response_error(self, logger):
        """
        1. Invalid parameters to Boto's EBS API calls
        raise the right exception after logging to Eliot.
        2. Verify Eliot log output for expected message fields
        from logging decorator for boto.exception.EC2Exception
        originating from boto.ec2.connection.EC2Connection.
        """
        # Test 1: Create volume with size 0.
        # Raises: ClientError
        self.assertRaises(ClientError, self.api.create_volume,
                          dataset_id=uuid4(), size=0,)

        # Test 2: Set EC2 connection zone to an invalid string.
        # Raises: ClientError
        self.api.zone = u'invalid_zone'
        self.assertRaises(
            ClientError,
            self.api.create_volume,
            dataset_id=uuid4(),
            size=self.minimum_allocatable_size,
        )

        # Validate decorated method for exception logging
        # actually logged to ``Eliot`` logger.
        expected_message_keys = {AWS_CODE.key, AWS_MESSAGE.key,
                                 AWS_REQUEST_ID.key}
        for logged in LoggedAction.of_type(logger.messages, AWS_ACTION,):
            key_subset = set(key for key in expected_message_keys
                             if key in logged.end_message.keys())
            self.assertEqual(expected_message_keys, key_subset)
开发者ID:332054781,项目名称:flocker,代码行数:33,代码来源:test_ebs.py

示例2: test_multiple_iterations

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def test_multiple_iterations(self, logger):
        """
        If the predicate returns something falsey followed by something truthy,
        then ``loop_until`` returns it immediately.
        """
        result = object()
        results = [None, False, result]
        expected_results = results[:-1]

        def predicate():
            return results.pop(0)

        clock = Clock()

        d = loop_until(clock, predicate)

        clock.advance(0.1)
        self.assertNoResult(d)
        clock.advance(0.1)

        self.assertEqual(self.successResultOf(d), result)

        action = LoggedAction.of_type(logger.messages, LOOP_UNTIL_ACTION)[0]
        assertContainsFields(self, action.start_message, {"predicate": predicate})
        assertContainsFields(self, action.end_message, {"result": result})
        self.assertTrue(action.succeeded)
        messages = LoggedMessage.of_type(logger.messages, LOOP_UNTIL_ITERATION_MESSAGE)
        self.assertEqual(action.children, messages)
        self.assertEqual([messages[0].message["result"], messages[1].message["result"]], expected_results)
开发者ID:ClusterHQ,项目名称:flocker,代码行数:31,代码来源:test_retry.py

示例3: test_iterates

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def test_iterates(self, logger):
        """
        If the predicate returns something falsey followed by something truthy,
        then ``loop_until`` returns it immediately.
        """
        result = object()
        results = [None, result]

        def predicate():
            return results.pop(0)
        clock = Clock()

        d = loop_until(clock, predicate)

        self.assertNoResult(d)

        clock.advance(0.1)
        self.assertEqual(
            self.successResultOf(d),
            result)

        action = LoggedAction.of_type(logger.messages, LOOP_UNTIL_ACTION)[0]
        assertContainsFields(self, action.start_message, {
            'predicate': predicate,
        })
        assertContainsFields(self, action.end_message, {
            'result': result,
        })
        self.assertTrue(action.succeeded)
        message = LoggedMessage.of_type(
            logger.messages, LOOP_UNTIL_ITERATION_MESSAGE)[0]
        self.assertEqual(action.children, [message])
        assertContainsFields(self, message.message, {
            'result': None,
        })
开发者ID:LeastAuthority,项目名称:leastauthority.com,代码行数:37,代码来源:test_retry.py

示例4: assertSearchLogging2

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def assertSearchLogging2(self, logger):
        """
        The two put actions are logged, followed by the two get actions.
        """
        [put1, put2] = LoggedAction.of_type(logger.messages, LOG_SEARCH_PUT)
        assertContainsFields(
            self, put1.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'e',
             'indexType': u'i',
             'searchType': u'type1',
             'result': u'result1'})
        assertContainsFields(
            self, put1.end_message,
            {'searchValue': u'value'})
        self.assertTrue(put1.succeeded)
        assertContainsFields(
            self, put2.start_message,
            {'searchClass': SearchClasses.PREFIX,
             'environment': u'e',
             'indexType': u'i',
             'searchType': u'type2',
             'result': u'result2'})
        assertContainsFields(
            self, put2.end_message,
            {'searchValue': u'value'})
        self.assertTrue(put2.succeeded)

        [get1, get2] = LoggedAction.of_type(logger.messages, LOG_SEARCH_GET)
        assertContainsFields(
            self, get1.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'e',
             'indexType': u'i',
             'searchValue': u'value',
             'searchType': None})
        assertContainsFields(self, get1.end_message, {'results': [u'result1']})
        self.assertTrue(get1.succeeded)
        assertContainsFields(
            self, get2.start_message,
            {'searchClass': SearchClasses.PREFIX,
             'environment': u'e',
             'indexType': u'i',
             'searchValue': u'va',
             'searchType': None})
        assertContainsFields(self, get2.end_message, {'results': [u'result2']})
        self.assertTrue(get2.succeeded)
开发者ID:featherlightly,项目名称:fusion-index,代码行数:49,代码来源:test_resource.py

示例5: assertSearchLogging

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def assertSearchLogging(self, logger):
        """
        The put action is logged, followed by the get action, followed by the
        delete, followed by the second get.
        """
        [put] = LoggedAction.of_type(logger.messages, LOG_SEARCH_PUT)
        assertContainsFields(
            self, put.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'someenv',
             'indexType': u'someindex',
             'result': u'result',
             'searchType': u'type'})
        assertContainsFields(
            self, put.end_message,
            {'searchValue': u'somevalue'})
        self.assertTrue(put.succeeded)

        [delete] = LoggedAction.of_type(logger.messages, LOG_SEARCH_DELETE)
        assertContainsFields(
            self, delete.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'someenv',
             'indexType': u'someindex',
             'result': u'result',
             'searchType': u'type'})
        self.assertTrue(delete.succeeded)

        [get1, get2] = LoggedAction.of_type(logger.messages, LOG_SEARCH_GET)
        assertContainsFields(
            self, get1.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'someenv',
             'indexType': u'someindex',
             'searchValue': u'somevalue',
             'searchType': None})
        assertContainsFields(self, get1.end_message, {'results': [u'result']})
        self.assertTrue(get1.succeeded)
        assertContainsFields(
            self, get2.start_message,
            {'searchClass': SearchClasses.EXACT,
             'environment': u'someenv',
             'indexType': u'someindex',
             'searchValue': u'somevalue',
             'searchType': None})
        assertContainsFields(self, get2.end_message, {'results': []})
        self.assertTrue(get2.succeeded)
开发者ID:featherlightly,项目名称:fusion-index,代码行数:49,代码来源:test_resource.py

示例6: assert_context_preserved

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
 def assert_context_preserved(self, logger):
     """
     Logging in the method running in the thread pool is child of caller's
     Eliot context.
     """
     parent = assertHasAction(self, logger, LOG_IN_CALLER, True, {})
     # in-between we expect a eliot:remote_task...
     self.assertIn(parent.children[0].children[0],
                   LoggedAction.of_type(logger.messages, LOG_IN_SPY))
开发者ID:332054781,项目名称:flocker,代码行数:11,代码来源:test_thread.py

示例7: test_run_successful_test

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
 def test_run_successful_test(self, logger):
     """
     Running a test with the Eliot reporter logs an action.
     """
     reporter = make_reporter()
     test = make_successful_test()
     test.run(reporter)
     [action] = LoggedAction.of_type(logger.serialize(), TEST)
     assertContainsFields(self, action.start_message, {"test": test.id()})
开发者ID:jml,项目名称:trial-eliot,代码行数:11,代码来源:test_reporter.py

示例8: test_successful_test

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
 def test_successful_test(self, logger):
     """
     Starting and stopping a test logs a whole action.
     """
     reporter = make_reporter()
     test = make_successful_test()
     reporter.startTest(test)
     reporter.stopTest(test)
     [action] = LoggedAction.of_type(logger.serialize(), TEST)
     assertContainsFields(self, action.start_message, {"test": test.id()})
开发者ID:jml,项目名称:trial-eliot,代码行数:12,代码来源:test_reporter.py

示例9: assertLookupLogging

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def assertLookupLogging(self, logger):
        """
        The put action is logged, followed by the get action.
        """
        [put] = LoggedAction.of_type(logger.messages, LOG_LOOKUP_PUT)
        assertContainsFields(
            self, put.start_message,
            {'environment': u'someenv',
             'indexType': u'sometype',
             'key': u'somekey'})
        assertContainsFields(self, put.end_message, {'value': b'data'})
        self.assertTrue(put.succeeded)

        [get] = LoggedAction.of_type(logger.messages, LOG_LOOKUP_GET)
        assertContainsFields(
            self, get.start_message,
            {'environment': u'someenv',
             'indexType': u'sometype',
             'key': u'somekey'})
        assertContainsFields(self, get.end_message, {'value': b'data'})
        self.assertTrue(get.succeeded)
开发者ID:featherlightly,项目名称:fusion-index,代码行数:23,代码来源:test_resource.py

示例10: assertMissingGetLogging

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
 def assertMissingGetLogging(self, logger):
     """
     When a I{GET} results in I{Not found}, a successful action is logged
     with a C{None} value.
     """
     [get] = LoggedAction.of_type(logger.messages, LOG_LOOKUP_GET)
     assertContainsFields(
         self, get.start_message,
         {'environment': u'someenv',
          'indexType': u'sometype',
          'key': u'somekey'})
     assertContainsFields(self, get.end_message, {'value': None})
     self.assertTrue(get.succeeded)
开发者ID:featherlightly,项目名称:fusion-index,代码行数:15,代码来源:test_resource.py

示例11: test_immediate_success

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def test_immediate_success(self, logger):
        """
        If the predicate returns something truthy immediately, then
        ``loop_until`` returns a deferred that has already fired with that
        value.
        """
        result = object()

        def predicate():
            return result

        clock = Clock()
        d = loop_until(clock, predicate)
        self.assertEqual(self.successResultOf(d), result)

        action = LoggedAction.of_type(logger.messages, LOOP_UNTIL_ACTION)[0]
        assertContainsFields(self, action.start_message, {"predicate": predicate})
        assertContainsFields(self, action.end_message, {"action_status": "succeeded", "result": result})
开发者ID:ClusterHQ,项目名称:flocker,代码行数:20,代码来源:test_retry.py

示例12: test_partial_predicate

# 需要导入模块: from eliot.testing import LoggedAction [as 别名]
# 或者: from eliot.testing.LoggedAction import of_type [as 别名]
    def test_partial_predicate(self, logger):
        """
        Predicate can be a functools.partial function.
        """
        result = object()

        def check():
            return result

        predicate = partial(check)

        clock = Clock()
        d = loop_until(clock, predicate)
        self.assertEqual(self.successResultOf(d), result)

        [action] = LoggedAction.of_type(logger.messages, LOOP_UNTIL_ACTION)
        assertContainsFields(self, action.start_message, {"predicate": predicate})
        assertContainsFields(self, action.end_message, {"action_status": "succeeded", "result": result})
开发者ID:ClusterHQ,项目名称:flocker,代码行数:20,代码来源:test_retry.py


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