Exemple #1
0
def test_without_fallback(headers, status_code, version):
    with app.test_client() as c:
        rv = c.get('/without-fallback', headers={'accept': headers})
        assert rv.status_code == status_code
        if rv.status_code < 300:
            assert version == json.loads(rv.data)['version']
        else:
            for accepted_type in index_without_fallback.accept_handlers:
                assert accepted_type in rv.data
Exemple #2
0
def test_without_fallback(headers, status_code, version):
    with app.test_client() as c:
        rv = c.get('/without-fallback', headers={'accept': headers})
        assert rv.status_code == status_code
        if rv.status_code < 300:
            assert version == json.loads(rv.data.decode())['version']
        else:
            for accepted_type in index_without_fallback.accept_handlers:
                assert accepted_type in rv.data.decode()
Exemple #3
0
def test_flask_restful_resource_with_fallback(headers, status_code, version):
    with app.test_client() as c:
        rv = c.get('/resource/with-fallback', headers={'accept': headers})
        assert rv.status_code == status_code
        if rv.status_code < 300:
            assert version == json.loads(rv.data.decode())['version']
Exemple #4
0
def test_with_double_wildcard(headers, status_code, rh):
    with app.test_client() as c:
        rv = c.get('/with-double-wildcard', headers={'accept': headers})
        if rv.status_code < 300:
            assert rh == json.loads(rv.data.decode())['rh']
Exemple #5
0
def test_with_fallback(headers, status_code, version):
    with app.test_client() as c:
        rv = c.get('/with-fallback', headers={'accept': headers})
        assert rv.status_code == status_code
        if rv.status_code < 300:
            assert version == json.loads(rv.data)['version']