示例#1
0
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(JSONObserverWrapper(ultimate_observer,
                                            sort_keys=True,
                                            indent=indent or None),
                        hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(cf_id_wrapper(get_fanout()))))))
示例#2
0
    def test_add_cf_id_to_cloud_feeds_events(self):
        """
        CF event dictionaries have an ID added to them, non-CF events do not.
        """
        obs = []
        id_observer = cf_id_wrapper(obs.append)
        id_observer({'cloud_feed': True, 'this': 'is a cf event'})
        id_observer({'this': 'is not a cf event'})

        def hex_repeat(num):
            return "[a-fA-F0-9]{{{num}}}".format(num=num)

        uuid_regex = "-".join([hex_repeat(i) for i in (8, 4, 4, 4, 12)])
        self.assertEqual(
            obs,
            [{'cloud_feed': True, 'this': 'is a cf event',
              'cloud_feed_id': matches(MatchesRegex(uuid_regex))},
             {'this': 'is not a cf event'}])
示例#3
0
文件: setup.py 项目: rackerlabs/otter
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(
            JSONObserverWrapper(
                ultimate_observer,
                sort_keys=True,
                indent=indent or None),
            hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(
                        cf_id_wrapper(
                            get_fanout()))))))
示例#4
0
    def test_add_cf_id_to_cloud_feeds_events(self):
        """
        CF event dictionaries have an ID added to them, non-CF events do not.
        """
        obs = []
        id_observer = cf_id_wrapper(obs.append)
        id_observer({'cloud_feed': True, 'this': 'is a cf event'})
        id_observer({'this': 'is not a cf event'})

        def hex_repeat(num):
            return "[a-fA-F0-9]{{{num}}}".format(num=num)

        uuid_regex = "-".join([hex_repeat(i) for i in (8, 4, 4, 4, 12)])
        self.assertEqual(obs,
                         [{
                             'cloud_feed': True,
                             'this': 'is a cf event',
                             'cloud_feed_id': matches(MatchesRegex(uuid_regex))
                         }, {
                             'this': 'is not a cf event'
                         }])