from flask.testing import FlaskClient from tests import test_client import pytest def test_homepage(test_client: FlaskClient): """ Tests that the main homepage loads correctly once the '/' endpoint is hit """ response = test_client.get('/') assert response.status_code == 302 response = test_client.get('/products') assert response.status_code == 308 def test_products(test_client: FlaskClient): """ Tests that a product page is displayed when hitting one of the product endpoints """ response = test_client.get('/products/2') assert response.status_code == 200 response = test_client.get('/products/50') assert response.status_code == 302 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