def test_to_json(): job = Job(0, 'uri', 'output_base', 'output_path') job.timestamp = None assert str(job) == json.dumps({ 'id': 0, 'input_uri': 'uri', 'output_base': 'output_base', 'output_path': 'output_path', 'params': None, 'timestamp': str(None), 'producer': None, 'consumer': None, 'processing_time': str(None) })
def _callback(ch, method, properties, body): ch.basic_ack(delivery_tag = method.delivery_tag) data = json.loads(body.decode('ascii')) received_job = Job.from_json(data['body']) channel.stop_consuming() received_job.timestamp = job.timestamp assert str(job) == str(received_job)
def test_send_job(): job = Job(0, 'uri', 'output_base', 'output_path') name = conf['modules'][0]['name'] p.send_job(name, job) connection = pika.BlockingConnection(pika.ConnectionParameters(host='127.0.0.1')) channel = connection.channel() channel.queue_declare(queue=name) channel.basic_qos(prefetch_count=1) def _callback(ch, method, properties, body): ch.basic_ack(delivery_tag = method.delivery_tag) data = json.loads(body.decode('ascii')) received_job = Job.from_json(data['body']) channel.stop_consuming() received_job.timestamp = job.timestamp assert str(job) == str(received_job) channel.basic_consume(_callback, queue=name) channel.start_consuming()
def test_save_job_data_mongo(): job = Job(1, 'uri', 'modules', '') m_m.save_job_data(job, data)
def test_process_mongo(): job = Job(1, 'uri', 'modules', '') m_m.process(job, data)
def test_from_json(): job = Job.from_json(json_str) job.timestamp = None assert str(job) == json_str
def test_init(): job = Job(1, 'uri', 'output_base', 'output_path')
def test_load_job_data_mongo(self): job = Job(1, 'uri', 'modules', 'temp.json') assert m_m.load_job_data(job) == data
def test_save_job_data_mongo(self): job = Job(1, 'uri', 'modules', 'temp.json') m_m.save_job_data(job, data)