diff options
| author | stilbruch <stilbruch@protonail.com> | 2022-05-04 18:13:20 -0500 |
|---|---|---|
| committer | stilbruch <stilbruch@protonail.com> | 2022-05-04 18:13:20 -0500 |
| commit | 6a92fe73a176164197706965c82ea98b08bbc2bd (patch) | |
| tree | b2ad6ba3ae765b35f8c50c491356ef4daadb4902 /app | |
| parent | cd14ca37470771042d05e2ece187acf568c41058 (diff) | |
| download | Strengthy-6a92fe73a176164197706965c82ea98b08bbc2bd.tar.xz Strengthy-6a92fe73a176164197706965c82ea98b08bbc2bd.zip | |
Fix tests
Diffstat (limited to 'app')
| -rw-r--r-- | app/app.py | 1 | ||||
| -rw-r--r-- | app/routes/__init__.py | 10 | ||||
| -rw-r--r-- | app/tables/__init__.py | 4 | ||||
| -rw-r--r-- | app/tests/conftest.py | 10 | ||||
| -rw-r--r-- | app/tests/functional/test_routes.py | 17 | ||||
| -rw-r--r-- | app/tests/test_tables.py | 32 | ||||
| -rwxr-xr-x | app/tests/unit/test_user_model.py | 11 | ||||
| -rw-r--r-- | app/tests/unit/test_workout_model.py | 0 |
8 files changed, 46 insertions, 39 deletions
@@ -17,7 +17,6 @@ login_manager.login_view = "/login" # Setup SQLAlchemy # https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/#a-minimal-application db = SQLAlchemy(app) -# TODO: do in script import tables.user db.create_all() diff --git a/app/routes/__init__.py b/app/routes/__init__.py index 74d72db..e75fa83 100644 --- a/app/routes/__init__.py +++ b/app/routes/__init__.py @@ -1,5 +1,5 @@ -from routes.api import * -from routes.basic import * -from routes.progress import * -from routes.user import * -from routes.workout import * +from .api import * +from .basic import * +from .progress import * +from .user import * +from .workout import * diff --git a/app/tables/__init__.py b/app/tables/__init__.py index e67eb21..4ee4f41 100644 --- a/app/tables/__init__.py +++ b/app/tables/__init__.py @@ -1,2 +1,2 @@ -from tables.user import User -from tables.workout import * +from .user import * +from .workout import * diff --git a/app/tests/conftest.py b/app/tests/conftest.py index 9facb1f..e13f987 100644 --- a/app/tests/conftest.py +++ b/app/tests/conftest.py @@ -1,6 +1,10 @@ import pytest -import tables -@pytest.fixture(scope='module') + +from app import app +from tables import User + + +@pytest.fixture(scope="module") def new_user(): - user = User('gymdude99', 'bench400soon!', 'gymdude99@gmail.com') + user = User("gymdude99", "bench400soon!", "gymdude99@gmail.com") return user diff --git a/app/tests/functional/test_routes.py b/app/tests/functional/test_routes.py deleted file mode 100644 index 81e2ce1..0000000 --- a/app/tests/functional/test_routes.py +++ /dev/null @@ -1,17 +0,0 @@ -from app import create_app - -def test_home_page(): - """ - GIVEN a Flask application configured for testing - WHEN the '/' page is requested (GET) - THEN check that the response is valid - """ - - flask_app = create_app('flask_test.cfg') - - with flask_app.test_client() as test_client: - response = test_client.get('/') - assert response.status_code == 200 - assert b"Welcome to Strengthy" in response.data - assert b"Strengthy is an open source fitness tracking applicatio that helps users meet their fitness goals." in response.data - assert b"To get started, Sign Up to create an account." in response.data diff --git a/app/tests/test_tables.py b/app/tests/test_tables.py new file mode 100644 index 0000000..bb6e617 --- /dev/null +++ b/app/tests/test_tables.py @@ -0,0 +1,32 @@ +from tables import User, Workout + + +def test_new_user(): + """ + GIVEN a User model + WHEN a new User is created + THEN check that the email, hashed_password, and role fields are defined correctly + """ + user = User("gymdude99", "bench400soon!", "gymdude99@gmail.com") + assert user.email == "gymdude99@gmail.com" + assert user.password != "bench400soon!" + # assert user.role == "user" + + +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 + """ + + # TODO other way to generate new user? + user = User("gymdude99", "bench400soon!", "gymdude99@gmail.com") + workout = Workout( + user, "Leg Day", [{"name": "Leg Press", "sets": 4, "units": 8, "type": "reps"}] + ) + + assert workout.user_id == user.id + assert workout.name == "Leg Day" + # assert len(workout.exercises) == 1 TODO: how to use sqlalchemy with tests + assert workout.exercises[0].name == "Leg Press" diff --git a/app/tests/unit/test_user_model.py b/app/tests/unit/test_user_model.py deleted file mode 100755 index 4b6c0b3..0000000 --- a/app/tests/unit/test_user_model.py +++ /dev/null @@ -1,11 +0,0 @@ -import tables -def test_new_user(): - """ - GIVEN a User model - WHEN a new User is created - THEN check that the email, hashed_password, and role fields are defined correctly - """ - user = User('gymdude99', 'bench400soon!', 'gymdude99@gmail.com') - assert user.email == 'gymdude99@gmail.com' - assert user.hashed_password != 'bench400soon!' - assert user.role == 'user' diff --git a/app/tests/unit/test_workout_model.py b/app/tests/unit/test_workout_model.py deleted file mode 100644 index e69de29..0000000 --- a/app/tests/unit/test_workout_model.py +++ /dev/null |
