def __init__(self, worker): self.options = worker.options self.config = worker.config self.spec = get_spec(vumi_resource_path(worker.options['specfile'])) self.delegate = TwistedDelegate() self.worker = worker self.amqp_client = None
def get_message_sender(self): '''Creates a new MessageSender object, with a fake amqp client''' message_sender = MessageSender('amqp-spec-0-8.xml', None) spec = get_spec(vumi_resource_path('amqp-spec-0-8.xml')) client = FakeAmqpClient(spec) message_sender.client = client return message_sender
def get_worker(self, **config): spec = get_spec(vumi_resource_path("amqp-spec-0-8.xml")) amq_client = fake_amqp.FakeAMQClient(spec, {}, self.broker) worker = TestWorker({}, config) worker._amqp_client = amq_client yield worker.startWorker() returnValue(worker)
def __init__( self, specfile, amqp_config, connected_callback, disconnected_callback): '''Factory that creates JunebugAMQClients. specfile - string of specfile name amqp_config - connection details for amqp server ''' self.connected_callback, self.disconnected_callback = ( connected_callback, disconnected_callback) self.amqp_config = amqp_config self.spec = get_spec(vumi_resource_path(specfile)) self.delegate = TwistedDelegate() super(AmqpFactory, self).__init__()
def test_make_campaign_path_abs(self): vumi_tests_path = os.path.dirname(__file__) vumi_path = os.path.dirname(os.path.dirname(vumi_tests_path)) self.assertEqual('/foo/bar', vumi_resource_path('/foo/bar')) self.assertEqual(os.path.join(vumi_path, 'vumi/resources/foo/bar'), vumi_resource_path('foo/bar'))
def get_fake_amq_client(broker=None): spec = get_spec(vumi_resource_path("amqp-spec-0-8.xml")) return FakeAMQClient(spec, {}, broker)
def _connect(self, worker, timeout, bindAddress): spec = get_spec(vumi_resource_path("amqp-spec-0-8.xml")) amq_client = FakeAMQClient(spec, self.options, self.broker) self.broker = amq_client.broker # So we use the same broker for all. reactor.callLater(0, worker._amqp_connected, amq_client)
def get_stubbed_worker(worker_class, config=None, broker=None): spec = get_spec(vumi_resource_path("amqp-spec-0-8.xml")) amq_client = FakeAMQClient(spec, {}, broker) worker = worker_class({}, config) worker._amqp_client = amq_client return worker
def get_stubbed_channel(broker=None, id=0): spec = get_spec(vumi_resource_path("amqp-spec-0-8.xml")) amq_client = FakeAMQClient(spec, {}, broker) return amq_client.channel(id)