Exemplo n.º 1
0
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)
        })
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
def test_save_job_data_mongo():
    job = Job(1, 'uri', 'modules', '')
    m_m.save_job_data(job, data)
Exemplo n.º 5
0
def test_process_mongo():
    job = Job(1, 'uri', 'modules', '')
    m_m.process(job, data)
Exemplo n.º 6
0
def test_from_json():
    job = Job.from_json(json_str)
    job.timestamp = None
    assert str(job) == json_str
Exemplo n.º 7
0
def test_init():
    job = Job(1, 'uri', 'output_base', 'output_path')
Exemplo n.º 8
0
 def test_load_job_data_mongo(self):
     job = Job(1, 'uri', 'modules', 'temp.json')
     assert m_m.load_job_data(job) == data
Exemplo n.º 9
0
 def test_save_job_data_mongo(self):
     job = Job(1, 'uri', 'modules', 'temp.json')
     m_m.save_job_data(job, data)