def index_from_mongo(hours, collection, timestamp, direction): print('Checking if elastic index exists, a new one will be created if not') app.data.init_elastic(app) print('Elastic index check has been completed') if timestamp: index_elastic_from_mongo_from_timestamp(collection, timestamp, direction) else: index_elastic_from_mongo(hours=hours, collection=collection)
def test_item_detail(app, client): remove_elastic_index(app) index_elastic_from_mongo() sleep(1) resp = client.get('/wire/tag:foo') assert resp.status_code == 200 html = resp.get_data().decode('utf-8') assert 'Amazon Is Opening More Bookstores' in html resp = client.get('/wire/%s/versions' % items[1]['_id']) data = json.loads(resp.get_data()) assert 2 == len(data['_items']) assert 'tag:weather' == data['_items'][0]['_id']
def test_index_from_mongo_collection(app, client): remove_elastic_index(app) app.data.init_elastic(app) sleep(1) index_elastic_from_mongo(collection='items') sleep(1) resp = client.get('/wire/tag:foo') assert resp.status_code == 200 html = resp.get_data().decode('utf-8') assert 'Amazon Is Opening More Bookstores' in html resp = client.get('/wire/search') assert resp.status_code == 200 data = json.loads(resp.get_data()) assert 3 == len(data['_items'])
def index_from_mongo(): print('Checking if elastic index exists, a new one will be created if not') app.data.init_elastic(app) print('Elastic index check has been completed') index_elastic_from_mongo()