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
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()
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']
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']
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']