summaryrefslogtreecommitdiff
path: root/app/tests/test_tables.py
blob: bb6e6176a7b89f18a53424ac7fdcb923d1e3b4ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"