def run_example(claims_file, queue='example', **kwargs): """ Reads input from a file and sends it to the queue :param: claims_file - path to the claims :type: str :param: queue - where to send the claims :type: str (example) :return: no return """ logger.info('Loading records from: {0}'.format(claims_file)) worker = ExampleWorker(params={ 'publish': queue, 'exchange': app.config.get('EXCHANGE', 'ADSDeploy-exchange') }) i = 0 worker.connect(app.config.get('RABBITMQ_URL')) with open(claims_file, 'r') as f: for line in f: worker.publish(line) i+=1 logger.info('Done processing {0} claims.'.format(i))
def test_example_worker(self, *args): """Check it is publishing data""" worker = ExampleWorker() worker.process_payload({u"foo": u"bar", u"baz": [1, 2]}) worker.publish.assert_called_with({u"foo": u"bar", u"baz": [1, 2]})