コード例 #1
0
ファイル: test_versioning.py プロジェクト: di/flask-accept
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
コード例 #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()
コード例 #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']
コード例 #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']
コード例 #5
0
ファイル: test_versioning.py プロジェクト: di/flask-accept
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']