Example #1
0
    def test_cloudfeeds_setup(self):
        """
        Cloud feeds observer is setup if it is there in config
        """
        self.addCleanup(set_fanout, None)
        self.assertEqual(get_fanout(), None)

        conf = deepcopy(test_config)
        conf['cloudfeeds'] = {
            'service': 'cloudFeeds',
            'tenant_id': 'tid',
            'url': 'url'
        }
        makeService(conf)
        serv_confs = get_service_configs(conf)
        serv_confs[ServiceType.CLOUD_FEEDS] = {'url': 'url'}

        self.assertEqual(len(get_fanout().subobservers), 1)
        cf_observer = get_fanout().subobservers[0]
        self.assertEqual(
            cf_observer,
            CloudFeedsObserver(reactor=self.reactor,
                               authenticator=matches(
                                   IsInstance(CachingAuthenticator)),
                               tenant_id='tid',
                               region='ord',
                               service_configs=serv_confs))

        # single tenant authenticator is created
        authenticator = cf_observer.authenticator
        self.assertIsInstance(
            authenticator._authenticator._authenticator._authenticator,
            SingleTenantAuthenticator)
Example #2
0
    def test_cloudfeeds_setup(self):
        """
        Cloud feeds observer is setup if it is there in config
        """
        self.addCleanup(set_fanout, None)
        self.assertEqual(get_fanout(), None)

        conf = deepcopy(test_config)
        conf['cloudfeeds'] = {'service': 'cloudFeeds', 'tenant_id': 'tid',
                              'url': 'url'}
        makeService(conf)
        serv_confs = get_service_configs(conf)
        serv_confs[ServiceType.CLOUD_FEEDS] = {'url': 'url'}

        self.assertEqual(len(get_fanout().subobservers), 1)
        cf_observer = get_fanout().subobservers[0]
        self.assertEqual(
            cf_observer,
            CloudFeedsObserver(
                reactor=self.reactor,
                authenticator=matches(IsInstance(CachingAuthenticator)),
                tenant_id='tid',
                region='ord',
                service_configs=serv_confs))

        # single tenant authenticator is created
        authenticator = cf_observer.authenticator
        self.assertIsInstance(
            authenticator._authenticator._authenticator._authenticator,
            SingleTenantAuthenticator)
Example #3
0
    def test_cloudfeeds_no_setup(self):
        """
        Cloud feeds observer is not setup if it is not there in config
        """
        self.addCleanup(set_fanout, None)
        self.assertEqual(get_fanout(), None)

        makeService(test_config)

        self.assertEqual(get_fanout(), None)
Example #4
0
    def test_cloudfeeds_no_setup(self):
        """
        Cloud feeds observer is not setup if it is not there in config
        """
        self.addCleanup(set_fanout, None)
        self.assertEqual(get_fanout(), None)

        makeService(test_config)

        self.assertEqual(get_fanout(), None)
Example #5
0
    def test_global_fanout(self):
        """
        Setting and getting and adding to the global fanout observer.
        """
        obs1, obs2 = [], []
        self.assertEqual(get_fanout(), None)

        # add_to_fanout when there is no fanout
        add_to_fanout(obs1.append)
        fanout = get_fanout()
        self.assertEqual(fanout.subobservers, [obs1.append])

        # add_to_fanout when there is already a fanout
        add_to_fanout(obs2.append)
        self.assertIs(get_fanout(), fanout)
        self.assertEqual(fanout.subobservers, [obs1.append, obs2.append])

        # set_fanout
        set_fanout(None)
        self.assertEqual(get_fanout(), None)
Example #6
0
    def test_global_fanout(self):
        """
        Setting and getting and adding to the global fanout observer.
        """
        obs1, obs2 = [], []
        self.assertEqual(get_fanout(), None)

        # add_to_fanout when there is no fanout
        add_to_fanout(obs1.append)
        fanout = get_fanout()
        self.assertEqual(fanout.subobservers, [obs1.append])

        # add_to_fanout when there is already a fanout
        add_to_fanout(obs2.append)
        self.assertIs(get_fanout(), fanout)
        self.assertEqual(fanout.subobservers, [obs1.append, obs2.append])

        # set_fanout
        set_fanout(None)
        self.assertEqual(get_fanout(), None)
Example #7
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()))))))
Example #8
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()))))))