

def test_nested_flask_views():
    app = Flask(__name__)
    admin = base.Admin(app)
    view = MockMethodView()
    admin.add_view(view)
    client = app.test_client()
    rv = client.get('/admin/mockmethodview/_api/1')
    print('"', rv.data, '"')
    eq_(rv.data, b'GET - API1')
    rv = client.put('/admin/mockmethodview/_api/1')
    eq_(rv.data, b'PUT - API1')
    rv = client.post('/admin/mockmethodview/_api/1')
    eq_(rv.data, b'POST - API1')
    rv = client.delete('/admin/mockmethodview/_api/1')
    eq_(rv.data, b'DELETE - API1')
    rv = client.get('/admin/mockmethodview/_api/2')
    eq_(rv.data, b'GET - API2')
    rv = client.post('/admin/mockmethodview/_api/2')
    eq_(rv.data, b'POST - API2')
    rv = client.delete('/admin/mockmethodview/_api/2')
    eq_(rv.status_code, 405)
    rv = client.put('/admin/mockmethodview/_api/2')
    eq_(rv.status_code, 405)
    rv = client.get('/admin/mockmethodview/_api/3')
    eq_(rv.data, b'GET - API3')
    rv = client.get('/admin/mockmethodview/_api/4')
    eq_(rv.data, b'GET - API3')

dataset/ETHPy150Open mrjoes/flask-admin/flask_admin/tests/test_base.py test_nested_flask_views/original