Ejemplo n.º 1
0
    def test_initialize(self, uuid):
        uuid.return_value = Mock(hex='my-uuid4')

        worker = HolmesWorker(['-c', join(self.root_path, 'tests/unit/test_worker.conf'), '--concurrency=10'])
        worker.initialize()

        expect(worker.uuid).to_equal('my-uuid4')

        expect(worker.facters).to_length(1)
        expect(worker.validators).to_length(1)

        expect(worker.otto).to_be_instance_of(TornadoOctopus)
Ejemplo n.º 2
0
    def test_initialize(self, uuid):
        uuid.return_value = Mock(hex='my-uuid4')

        worker = HolmesWorker(['-c', join(self.root_path, 'tests/unit/test_worker.conf'), '--concurrency=10'])
        worker.initialize()

        expect(worker.uuid).to_equal('my-uuid4')

        expect(worker.facters).to_length(1)
        expect(worker.validators).to_length(1)

        expect(worker.otto).to_be_instance_of(TornadoOctopus)

        expect(worker.girl).to_be_instance_of(Materializer)
Ejemplo n.º 3
0
    def test_load_all_domains_violations_prefs(self):
        worker = HolmesWorker(['-c', join(self.root_path, 'tests/unit/test_worker.conf'), '--concurrency=10'])

        worker.initialize()

        # Same instance of DB, for sqlalchemy runs on Vegas
        bkp_db = worker.db
        worker.db = self.db
        worker.cache.db = self.db

        domain = DomainFactory.create(name='globo.com')

        worker.cache.redis.delete('violations-prefs-%s' % domain.name)

        prefs = worker.cache.redis.get('violations-prefs-%s' % domain.name)
        expect(prefs).to_be_null()

        for i in range(3):
            DomainsViolationsPrefsFactory.create(
                domain=domain,
                key=KeyFactory.create(name='some.random.%d' % i),
                value='v%d' % i
            )

        worker.load_all_domains_violations_prefs()

        prefs = worker.cache.get_domain_violations_prefs('globo.com')

        expect(prefs).to_equal([
            {'value': u'v0', 'key': u'some.random.0'},
            {'value': u'v1', 'key': u'some.random.1'},
            {'value': u'v2', 'key': u'some.random.2'}
        ])

        # Back to the wonderland
        worker.db = bkp_db
        worker.cache.db = bkp_db