diff options
| author | FivePixels <o5pxels@gmail.com> | 2022-05-04 16:08:11 -0500 |
|---|---|---|
| committer | FivePixels <o5pxels@gmail.com> | 2022-05-04 16:08:11 -0500 |
| commit | bbb1b6dba1e856872362f66d9c387e0a9e7e0a0f (patch) | |
| tree | 6c88aa71aa65a14caa525501094b29e1cf5eff66 | |
| parent | 22ec1a4502a105eaf575e3209b83af72be685929 (diff) | |
| download | Strengthy-bbb1b6dba1e856872362f66d9c387e0a9e7e0a0f.tar.xz Strengthy-bbb1b6dba1e856872362f66d9c387e0a9e7e0a0f.zip | |
Add pytest tests, not functionally working yet.
| -rw-r--r-- | app/tests/conftest.py | 6 | ||||
| -rw-r--r-- | app/tests/functional/test_routes.py | 17 | ||||
| -rwxr-xr-x | app/tests/unit/test_user_model.py | 11 | ||||
| -rw-r--r-- | app/tests/unit/test_workout_model.py | 0 | ||||
| -rw-r--r-- | requirements.txt | 1 |
5 files changed, 35 insertions, 0 deletions
diff --git a/app/tests/conftest.py b/app/tests/conftest.py new file mode 100644 index 0000000..9facb1f --- /dev/null +++ b/app/tests/conftest.py @@ -0,0 +1,6 @@ +import pytest +import tables +@pytest.fixture(scope='module') +def new_user(): + 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 new file mode 100644 index 0000000..81e2ce1 --- /dev/null +++ b/app/tests/functional/test_routes.py @@ -0,0 +1,17 @@ +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/unit/test_user_model.py b/app/tests/unit/test_user_model.py new file mode 100755 index 0000000..4b6c0b3 --- /dev/null +++ b/app/tests/unit/test_user_model.py @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/tests/unit/test_workout_model.py diff --git a/requirements.txt b/requirements.txt index 2bc12bc..67af28c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ flask flask_login flask_SQLAlchemy flask_wtf +pytest |
