Esempio n. 1
0
def api_get(url, display=False, check=True, *args, **kwargs):
    """
    call api, check response status code, and return json as dict
    """
    tester = app.test_client()
    resp = tester.get(url, *args, **kwargs)
    if check:
        assert resp.status_code == 200
        return _to_json(resp.data, display)
    else:
        return _to_json(resp.data, display), resp.status_code
Esempio n. 2
0
def test_post_pbf(create_instance_fr, enable_mimir2):
    assert not os.path.isfile('/tmp/empty_pbf.osm.pbf')

    filename = 'empty_pbf.osm.pbf'
    path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tests/fixtures/', filename)
    f = open(path, 'rb')
    try:
        files = {'file': (f, filename)}
        tester = app.test_client()
        resp = tester.post('/v0/jobs/fr', data=files)
    finally:
        f.close()
    assert resp.status_code == 200
    assert os.path.isfile('/tmp/empty_pbf.osm.pbf')

    os.remove('/tmp/empty_pbf.osm.pbf')
    assert not os.path.isfile('/tmp/empty_pbf.osm.pbf')
Esempio n. 3
0
def test_post_bad_instance(create_instance_fr):
    tester = app.test_client()
    resp = tester.post('/v0/jobs/fr_ko')
    assert resp.status_code == 404
Esempio n. 4
0
def test_post_no_file(create_instance_fr, enable_mimir2):
    tester = app.test_client()
    resp = tester.post('/v0/jobs/fr')
    assert resp.status_code == 400