From 970277e71272687c16d75ffa73fcbb461a1fee80 Mon Sep 17 00:00:00 2001 From: stilbruch Date: Fri, 6 May 2022 14:19:14 -0500 Subject: Add a few more tests and update project outline --- app/tests/conftest.py | 6 ++++++ app/tests/test_routes.py | 24 ++++++++++++++++++++++++ app/tests/test_tables.py | 2 +- docs/project_outline.tex | 7 ++++--- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 app/tests/test_routes.py diff --git a/app/tests/conftest.py b/app/tests/conftest.py index e13f987..849b5c5 100644 --- a/app/tests/conftest.py +++ b/app/tests/conftest.py @@ -4,6 +4,12 @@ from app import app from tables import User +@pytest.fixture +def client(): + with app.test_client() as client: + yield client + + @pytest.fixture(scope="module") def new_user(): user = User("gymdude99", "bench400soon!", "gymdude99@gmail.com") diff --git a/app/tests/test_routes.py b/app/tests/test_routes.py new file mode 100644 index 0000000..c03238e --- /dev/null +++ b/app/tests/test_routes.py @@ -0,0 +1,24 @@ +import pytest + +from app import app + + +def test_index(client): + resp = client.get("/") + + assert b"Welcome to Strengthy" in resp.data + + +# horrible name +def test_workout_create_notloggedin(client): + resp = client.get("/workout/create", follow_redirects=True) + + # Make sure redirect worked + assert resp.request.path == "/login" + + +def test_home_notloggedin(client): + resp = client.get("/home", follow_redirects=True) + + # Make sure redirect worked + assert resp.request.path == "/login" diff --git a/app/tests/test_tables.py b/app/tests/test_tables.py index bb6e617..ba7ac10 100644 --- a/app/tests/test_tables.py +++ b/app/tests/test_tables.py @@ -17,7 +17,7 @@ def test_new_workout(): """ GIVEN a Workout model WHEN a new Workout is created - THEN check that the email, hashed_password, and role fields are defined correctly + THEN check that the user_id, name, and exercises fields are defined correctly """ # TODO other way to generate new user? diff --git a/docs/project_outline.tex b/docs/project_outline.tex index 4fe0239..c0de40a 100644 --- a/docs/project_outline.tex +++ b/docs/project_outline.tex @@ -225,10 +225,11 @@ The web application will be developed in Python using the Flask framework. A dat \item[Environment] For the project, Hayden was developing on Void Linux while Dylan was developing on Arch Linux. Both of our environments typically involved a web browser and the command line. \item[Tools] For our tools, we both used the code editor Vim, each with plugins installed to ease development. For source control, we used Git and hosted the source on a VPS. Typically to locally develop and test the web application, we would use the 'flask run' command on the project to start a local instance of the Flask web app. \end{description} + \subsection{Reused Components} +Objects stored in the database such as workouts and users are represented as classes which are used to access data. These classes are also reused to store data in the database using SqlAlchemy annotations. When rendering html pages, the basic header is reused across all pages using jinja2 templates. -\section{Testing} -\subsection{Scenarios} -\subsection{Results} +\subsection{Testing Scenarios} +Basic object creation is tested to ensure that an object’s fields are being properly populated. Routes are also tested to ensure that if a user who isn’t logged in tries to access certain pages, they are redirected to login. \end{document} -- cgit v1.2.3