Worker unit tests
This commit is contained in:
parent
9117fd408c
commit
b788ebafa2
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
||||
|
||||
*.pyc
|
||||
local_settings.py
|
||||
.coverage
|
||||
worker.log
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
nosetests tests --exclude-dir=stacktach --with-coverage --cover-package=stacktach
|
||||
nosetests tests --exclude-dir=stacktach --with-coverage --cover-package=stacktach,worker
|
||||
|
36
tests/unit/test_worker.py
Normal file
36
tests/unit/test_worker.py
Normal file
@ -0,0 +1,36 @@
|
||||
import unittest
|
||||
|
||||
import kombu
|
||||
import kombu.entity
|
||||
import mox
|
||||
|
||||
import worker.worker as worker
|
||||
|
||||
class NovaConsumerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mox = mox.Mox()
|
||||
|
||||
def test_get_consumer(self):
|
||||
created_queues = None
|
||||
created_callback = None
|
||||
created_consumers = []
|
||||
def Consumer(queues=None, callbacks=None):
|
||||
created_queues = queues
|
||||
created_callback = callbacks
|
||||
consumer = self.mox.CreateMockAnything()
|
||||
created_consumers.append(consumer)
|
||||
return consumer
|
||||
self.mox.StubOutClassWithMocks(kombu.entity, 'Exchange')
|
||||
self.mox.StubOutClassWithMocks(kombu, 'Queue')
|
||||
kombu.entity.Exchange('nova', type='topic', exclusive=False,
|
||||
durable=True, auto_delete=False)
|
||||
kombu.Queue('monitor.info', kombu.entity.Exchange, auto_delete=False,
|
||||
durable=True, exclusive=False, routing_key='monitor.info')
|
||||
kombu.Queue('monitor.error', kombu.entity.Exchange, auto_delete=False,
|
||||
durable=True, exclusive=False, routing_key='monitor.error')
|
||||
consumer = worker.NovaConsumer('test', None, None, True)
|
||||
self.mox.ReplayAll()
|
||||
consumers = consumer.get_consumers(Consumer, None)
|
||||
self.assertEqual(len(consumers), len(created_consumers))
|
||||
self.assertEqual(consumers[0], created_consumers[0])
|
||||
self.mox.VerifyAll()
|
0
worker/__init__.py
Normal file
0
worker/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user