mirror of
https://github.com/Doctorado-ML/beflask.git
synced 2025-08-15 07:05:51 +00:00
refactor tests
This commit is contained in:
@@ -36,21 +36,21 @@ def auth(client):
|
||||
|
||||
@pytest.fixture
|
||||
def app(admin_user, admin_password):
|
||||
socketio, app = application.create_app("testing")
|
||||
app = application.create_app("testing")
|
||||
app.test_client_class = FlaskLoginClient
|
||||
with app.app_context():
|
||||
db_seed(db, admin_user, admin_password)
|
||||
return socketio, app
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return app[1].test_client()
|
||||
return app.test_client()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner(app):
|
||||
return app[1].test_cli_runner()
|
||||
return app.test_cli_runner()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@@ -2,7 +2,7 @@ from flask import session, g, url_for
|
||||
|
||||
|
||||
def test_login(app, client, auth, admin_user, admin_password):
|
||||
with app[1].test_request_context():
|
||||
with app.test_request_context():
|
||||
url_login = url_for("main.login")
|
||||
url_index = url_for("main.index")
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_login_invalid(auth, admin_user):
|
||||
|
||||
|
||||
def test_access_page_not_logged(client, app, auth, guest_user, guest_password):
|
||||
with app[1].test_request_context():
|
||||
with app.test_request_context():
|
||||
url_login = url_for("main.login")
|
||||
url_config = url_for("main.config")
|
||||
# Check if a not logged in user is redirected to login with next param
|
||||
|
@@ -2,9 +2,9 @@ from flask import url_for, g
|
||||
from beflask import app
|
||||
|
||||
|
||||
# def test_config_init():
|
||||
# assert not app.create_app()[1].testing
|
||||
# assert app.create_app("testing")[1].testing
|
||||
def test_config_init():
|
||||
assert not app.create_app().testing
|
||||
assert app.create_app("testing").testing
|
||||
|
||||
|
||||
def test_index(client):
|
||||
@@ -30,7 +30,7 @@ def test_index_logged(client, auth):
|
||||
|
||||
def test_set_benchmark_guest(client, auth, app):
|
||||
assert auth.login(follow_redirects=True).status_code == 200
|
||||
with app[1].test_request_context():
|
||||
with app.test_request_context():
|
||||
url = url_for("main.set_benchmark", benchmark_id=1)
|
||||
with client:
|
||||
response = client.get(url, follow_redirects=True)
|
||||
@@ -51,7 +51,7 @@ def test_set_benchmark_admin(client, auth, app, admin_user, admin_password):
|
||||
).status_code
|
||||
== 200
|
||||
)
|
||||
with app[1].test_request_context():
|
||||
with app.test_request_context():
|
||||
url = url_for("main.set_benchmark", benchmark_id=1)
|
||||
with client:
|
||||
response = client.get(url, follow_redirects=True)
|
||||
@@ -94,7 +94,7 @@ def test_config(app, client, auth):
|
||||
"framework": "HTML Framework default used in be_flask command",
|
||||
}
|
||||
assert auth.login(follow_redirects=True).status_code == 200
|
||||
with app[1].test_request_context():
|
||||
with app.test_request_context():
|
||||
url = url_for("main.config")
|
||||
with client:
|
||||
response = client.get(url)
|
||||
|
Reference in New Issue
Block a user