def create_layer(client): client.post(url_for('upload_layer'), files={'file': (FILE_NAME, open(PATH, "rb"))}, data={ 'color': COLOR, 'fill': FILL })
def test_get_celery_up(self, client, celery_up, cache_up): url = url_for('health_check') resp = client.get(url) data = resp.json() assert data['checks'][1]['name'] == CELERY_SERVICE assert data['checks'][1]['status'] == UP
def test_get_check_services(self, client, cache_name_memcached): url = url_for('health_services') resp = client.get(url) assert DB_SERVICE in resp.json() assert MEM_CACHED_SERVICE in resp.json() assert CELERY_SERVICE in resp.json()
def test_post_204(self, client): resp = client.post(url_for('upload_layer'), files={'file': (FILE_NAME, open(PATH, "rb"))}, data={ 'color': COLOR, 'fill': FILL }) assert resp.status_code == status.HTTP_204_NO_CONTENT
def test_get_db_down(self, client, db_down, celery_up, cache_up): url = url_for('health_check') resp = client.get(url) data = resp.json() assert data['status'] == DOWN assert data['checks'][0]['name'] == DB_SERVICE assert data['checks'][0]['status'] == DOWN
def test_get_cache_up(self, client, celery_up, cache_up, cache_name_memcached): url = url_for('health_check') resp = client.get(url) data = resp.json() assert data['checks'][2]['name'] == MEM_CACHED_SERVICE assert data['checks'][2]['status'] == UP
def test_get_layers_data(self, client): resp = client.get(url_for('get_layers')) data = resp.json() lyr = list(data.values())[0] assert lyr['nome'] == NAME assert lyr['color'] == COLOR assert lyr['fill'] is FILL assert lyr['show'] is False
def created_layer(client): client.post(url_for('upload_layer'), files={'file': (FILE_NAME, open(PATH, "rb"))}, data={ 'color': COLOR, 'fill': FILL }) with SYNC_DB.engine().connect() as conn: row = conn.execute(t_layer.select()) row = row.fetchone() return {'id': row.id}
def test_download_file(self, client, tmp_path): for fname in os.listdir(FILE_MODELS_PATH): print(f'>>> Testing download: {fname}') url = url_for('file_models_download', fname=fname) resp = client.get(url) outpath = tmp_path / fname with open(outpath, 'wb') as f: f.write(resp.content) assert os.path.exists(outpath)
def create_layer(client): with SYNC_DB.engine().connect() as conn: # TODO: passar este sql para ORM conn.execute('truncate table layers.layer cascade;') client.post( url_for('upload_layer'), files={'file': (FILE_NAME, open(PATH, "rb"))}, data={'color': COLOR, 'fill': FILL} )
def test_get_mvt_success(self, client, created_layer): id_lyr = created_layer['id'] resp = client.get( url_for( 'get_mvt_layer', **{ 'layer_id': id_lyr, 'z': 7, 'x': 46, 'y': 66, 'fmt': 'pbf' })) assert resp.status_code == status.HTTP_200_OK
def test_download_valid_file(self, client, tmp_path): url = url_for('file_models_download', fname=TEST_FNAME) resp = client.get(url) outpath = tmp_path / TEST_FNAME with open(outpath, 'wb') as f: f.write(resp.content) shp = ShapefileCompressed(Shapefile(str(outpath)), compress_engine=Zip()) geomc = json.loads(shp.geometry_collection()) assert len(geomc['geometries']) == SIMPLE_POLY_GEOM_LEN
def test_get_mvt_empty(self, client, created_layer): id_lyr = created_layer['id'] resp = client.get( url_for( 'get_mvt_layer', **{ 'layer_id': id_lyr, 'z': 1, 'x': 1, 'y': 1, 'fmt': 'pbf' })) assert resp.content == b''
def test_get_app_up(self, client, celery_up, cache_up): url = url_for('health_check') resp = client.get(url) data = resp.json() assert data['status'] == UP
def test_get_success(self, client, celery_up, cache_up): url = url_for('health_check') resp = client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_get_inexisting_service_code(self, client): url = url_for('health_detail', service_name=INEXISTING_SERVICE) resp = client.get(url) assert resp.json()['detail']['code'] == INEXISTING_SERVICE
def test_get_inexisting_service_msg(self, client): url = url_for('health_detail', service_name=INEXISTING_SERVICE) resp = client.get(url) assert bool(resp.json()['detail']['msg'])
def test_get_inexisting_service_status_400(self, client): url = url_for('health_detail', service_name=INEXISTING_SERVICE) resp = client.get(url) assert resp.status_code == status.HTTP_400_BAD_REQUEST
def test_get_cache_detail(self, client, cache_detail, cache_name_memcached): url = url_for('health_detail', service_name=MEM_CACHED_SERVICE) resp = client.get(url) assert resp.json() == SOME_DICT_INFO
def test_list_check_data(self, client): resp = client.get(url_for('list_all_tasks_save_layer')) task_data = resp.json()[0] assert task_data['layer_name'] == NAME assert task_data['status'] == WORKER_STATUS_SUCCESS
def test_get_celery_detail(self, client, celery_detail): url = url_for('health_detail', service_name=CELERY_SERVICE) resp = client.get(url) assert resp.json() == SOME_DICT_INFO
def test_get_celery_info_success(self, client, celery_detail): url = url_for('health_detail', service_name=CELERY_SERVICE) resp = client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_list_success(self, client): resp = client.get(url_for('list_all_tasks_save_layer')) assert resp.status_code == status.HTTP_200_OK
def test_get_cache_down_msg(self, client, celery_up, cache_down): url = url_for('health_check') resp = client.get(url) data = resp.json() assert data['checks'][2]['msg'] == SOME_MSG
def test_download_inexisting_file_code(self, client): url = url_for('file_models_download', fname=INEXISTING_FILE) resp = client.get(url) assert resp.json()['detail']['code'] == INEXISTING_FILE_MODEL
def test_get_cache_info_success(self, client, cache_detail, cache_name_memcached): url = url_for('health_detail', service_name=MEM_CACHED_SERVICE) resp = client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_get_data(self, client): url = url_for('file_models_list') resp = client.get(url) assert os.listdir(FILE_MODELS_PATH) == resp.json()
def test_list_check_id(self, client): resp = client.get(url_for('list_all_tasks_save_layer')) task_data = resp.json()[0] assert is_uuid(task_data['id'])
def test_get_sucess(self, client): url = url_for('health_services') resp = client.get(url) assert resp.status_code == status.HTTP_200_OK
def test_get_success(self, client): url = url_for('file_models_list') resp = client.get(url) assert resp.status_code == status.HTTP_200_OK