From 6a92fe73a176164197706965c82ea98b08bbc2bd Mon Sep 17 00:00:00 2001 From: stilbruch Date: Wed, 4 May 2022 18:13:20 -0500 Subject: Fix tests --- app/tests/test_tables.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/tests/test_tables.py (limited to 'app/tests/test_tables.py') 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" -- cgit v1.2.3