#11 Added extra functional tests for admin endpoints
This commit is contained in:
parent
263bea92f4
commit
d056146a44
@ -0,0 +1,16 @@
|
||||
from app import app
|
||||
from flask.testing import FlaskClient
|
||||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def test_client() -> FlaskClient:
|
||||
""" Test that required environment variables are set
|
||||
ahead of runtime
|
||||
"""
|
||||
os.environ['CONFIG_TYPE'] = 'config.TestingConfig'
|
||||
|
||||
with app.test_client() as testing_client:
|
||||
with app.app_context():
|
||||
yield testing_client
|
@ -1,19 +1,6 @@
|
||||
from app import app
|
||||
from flask.testing import FlaskClient
|
||||
from tests.functional import test_client
|
||||
import pytest
|
||||
import os
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def test_client() -> FlaskClient:
|
||||
""" Test that required environment variables are set
|
||||
ahead of runtime
|
||||
"""
|
||||
os.environ['CONFIG_TYPE'] = 'config.TestingConfig'
|
||||
|
||||
with app.test_client() as testing_client:
|
||||
with app.app_context():
|
||||
yield testing_client
|
||||
|
||||
|
||||
def test_homepage(test_client: FlaskClient):
|
||||
@ -39,3 +26,14 @@ def test_products(test_client: FlaskClient):
|
||||
|
||||
response = test_client.get('/products/Books')
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_admin(test_client: FlaskClient):
|
||||
""" Tests that the admin pages can be reached and redirect
|
||||
upon reaching
|
||||
"""
|
||||
response = test_client.get('/admin/users/')
|
||||
assert response.status_code == 302
|
||||
|
||||
response = test_client.get('/admin/products/')
|
||||
assert response.status_code == 302
|
||||
|
Loading…
Reference in New Issue
Block a user