Repository: santosderek/Vitality

Issue:
Add repr functions
**What would you like to add?**
Add repr functions to workout, trainee, trainer, invitation, user. 

**Describe the solution you'd like (If needed)**
- [x] Add repr functions to workout
- [x] Add repr functions to trainee
- [x] Add repr functions to trainer
- [x] Add repr functions to invitation
- [x] Add repr functions to user 


Discussion:

Patch:
diff --git a/vitality/trainer.py b/vitality/trainer.py
index 00199da..67c5416 100644
--- a/vitality/trainer.py
+++ b/vitality/trainer.py
@@ -3,34 +3,10 @@ from .user import User
 
 class Trainer(User):
     def __init__(self,
-                 _id: str,
-                 username: str,
-                 password: str,
-                 name: str = None,
-                 location: str = None,
-                 phone: int = None,
-                 body_type: str = None,
-                 body_fat: str = None,
-                 height: str = None,
-                 weight: str = None,
-                 exp: str = None,
-                 goal_weight: str = None,
-                 goal_body_fat: str = None,
-                 trainees=[]):
+                 trainees=[],
+                 **kwargs):
         """Constructor for Trainer."""
-        super().__init__(_id,
-                         username,
-                         password,
-                         name,
-                         location,
-                         phone,
-                         body_type,
-                         body_fat,
-                         height,
-                         weight,
-                         exp,
-                         goal_weight,
-                         goal_body_fat)
+        super().__init__(**kwargs)
         self.trainees = trainees
 
     def __repr__(self):
diff --git a/vitality/workout.py b/vitality/workout.py
index baa17d7..1976613 100644
--- a/vitality/workout.py
+++ b/vitality/workout.py
@@ -8,6 +8,10 @@ class Workout:
         self.about = about
         self.exp = exp
 
+    def __repr__(self):
+        """Returns all attributes of the Workout class as a dictionary."""
+        return f'Workout({self._id}, {self.creator_id}, {self.name}, {self.difficulty}, {self.about}, {self.exp})'
+
     def as_dict(self):
         """Returns all attributes of the Workout class as a dictionary."""
         return dict(self.__dict__)


Test patch:
diff --git a/tests/test_trainee.py b/tests/test_trainee.py
index 2640563..b6d07ca 100644
--- a/tests/test_trainee.py
+++ b/tests/test_trainee.py
@@ -2,32 +2,108 @@ import unittest
 from vitality.trainee import Trainee
 
 
-class TestUser(unittest.TestCase):
-
-    def test_as_dict(self):
-
-        new_user = Trainee(_id=0, username="test", password="password",
-                           name="first last", location="Earth", phone=1234567890, trainers=[])
-
-        new_dict = new_user.as_dict()
-        comp_dict = {
-            "_id": 0,
-            "username": "test",
-            "password": "password",
-            "name": "first last",
-            "location": "Earth",
-            "phone": 1234567890,
-            'trainers': [],
-            "body_type": None,
-            "body_fat": None,
-            "height": None,
-            "weight": None,
-            "exp": None,
-            "goal_weight": None,
-            "goal_body_fat": None
-        }
-
-        self.assertTrue(new_dict == comp_dict)
+def test_as_dict():
+
+    trainee = Trainee(
+        _id="000000000000000000000001",
+        username="trainee",
+        password="newPassword",
+        name="test trainee",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainers=[
+            "000000000000000000000002"
+        ]
+    )
+
+    new_dict = trainee.as_dict()
+    comp_dict = dict(
+        _id="000000000000000000000001",
+        username="trainee",
+        password="newPassword",
+        name="test trainee",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainers=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert new_dict == comp_dict
+
+
+def test_initalization():
+    trainee = Trainee(
+        _id="000000000000000000000001",
+        username="trainee",
+        password="newPassword",
+        name="test trainee",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainers=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert trainee._id == '000000000000000000000001'
+    assert trainee.username == 'trainee'
+    assert trainee.password == "newPassword"
+    assert trainee.name == "test trainee"
+    assert trainee.location == "mars"
+    assert trainee.phone == "1234567890"
+    assert trainee.body_type == "big"
+    assert trainee.body_fat == "fat"
+    assert trainee.height == "7"
+    assert trainee.weight == "100"
+    assert trainee.exp == "12345"
+    assert trainee.goal_weight == "95"
+    assert trainee.goal_body_fat == "notfat"
+    assert trainee.trainers == ["000000000000000000000002"]
+
+
+def test_repr():
+    trainee = Trainee(
+        _id="000000000000000000000001",
+        username="trainee",
+        password="newPassword",
+        name="test trainee",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainers=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert repr(trainee) \
+        == "Trainee(000000000000000000000001, trainee, newPassword, test trainee, mars, 1234567890, big, fat, 7, 100, 12345, 95, notfat, [\'000000000000000000000002\'])"
 
 
 if __name__ == '__main__':
diff --git a/tests/test_trainer.py b/tests/test_trainer.py
index ae0b29c..5e595e2 100644
--- a/tests/test_trainer.py
+++ b/tests/test_trainer.py
@@ -2,36 +2,105 @@ import unittest
 from vitality.trainer import Trainer
 
 
-class TestTrainer(unittest.TestCase):
-
-    def test_as_dict(self):
-
-        new_trainer = Trainer(
-            _id="0",
-            username="test",
-            password="password",
-            trainees=[],
-            name="first last",
-            location="Earth",
-            phone=1234567890
-        )
-
-        new_dict = new_trainer.as_dict()
-        comp_dict = {
-            "_id": "0",
-            "username": "test",
-            "password": "password",
-            "trainees": [],
-            "name": "first last",
-            "location": "Earth",
-            "phone": 1234567890,
-            "body_type": None,
-            "body_fat": None,
-            "height": None,
-            "weight": None,
-            "exp": None,
-            "goal_weight": None,
-            "goal_body_fat": None
-        }
-
-        self.assertTrue(new_dict == comp_dict)
+def test_as_dict():
+
+    trainer = Trainer(
+        _id="000000000000000000000001",
+        username="trainer",
+        password="newPassword",
+        name="test trainer",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainees=[
+            "000000000000000000000002"
+        ]
+    )
+
+    new_dict = trainer.as_dict()
+    comp_dict = dict(
+        _id="000000000000000000000001",
+        username="trainer",
+        password="newPassword",
+        name="test trainer",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainees=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert new_dict == comp_dict
+
+
+def test_initalization():
+    trainer = Trainer(
+        _id="000000000000000000000001",
+        username="trainer",
+        password="newPassword",
+        name="test trainer",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainees=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert trainer._id == '000000000000000000000001'
+    assert trainer.username == 'trainer'
+    assert trainer.password == "newPassword"
+    assert trainer.name == "test trainer"
+    assert trainer.location == "mars"
+    assert trainer.phone == "1234567890"
+    assert trainer.body_type == "big"
+    assert trainer.body_fat == "fat"
+    assert trainer.height == "7"
+    assert trainer.weight == "100"
+    assert trainer.exp == "12345"
+    assert trainer.goal_weight == "95"
+    assert trainer.goal_body_fat == "notfat"
+    assert trainer.trainees == ["000000000000000000000002"]
+
+
+def test_repr():
+    trainer = Trainer(
+        _id="000000000000000000000001",
+        username="trainer",
+        password="newPassword",
+        name="test trainer",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+        trainees=[
+            "000000000000000000000002"
+        ]
+    )
+
+    assert repr(
+        trainer) == "Trainer(000000000000000000000001, trainer, newPassword, test trainer, mars, 1234567890, big, fat, 7, 100, 12345, 95, notfat, [\'000000000000000000000002\'])"
diff --git a/tests/test_user.py b/tests/test_user.py
new file mode 100644
index 0000000..864ce70
--- /dev/null
+++ b/tests/test_user.py
@@ -0,0 +1,97 @@
+import unittest
+from vitality.user import User
+
+
+def test_as_dict():
+
+    user = User(
+        _id="000000000000000000000001",
+        username="user",
+        password="newPassword",
+        name="test user",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat"
+    )
+
+    new_dict = user.as_dict()
+    comp_dict = dict(
+        _id="000000000000000000000001",
+        username="user",
+        password="newPassword",
+        name="test user",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat"
+    )
+
+    assert new_dict == comp_dict
+
+
+def test_initalization():
+    user = User(
+        _id="000000000000000000000001",
+        username="user",
+        password="newPassword",
+        name="test user",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat"
+    )
+
+    assert user._id == '000000000000000000000001'
+    assert user.username == 'user'
+    assert user.password == "newPassword"
+    assert user.name == "test user"
+    assert user.location == "mars"
+    assert user.phone == "1234567890"
+    assert user.body_type == "big"
+    assert user.body_fat == "fat"
+    assert user.height == "7"
+    assert user.weight == "100"
+    assert user.exp == "12345"
+    assert user.goal_weight == "95"
+    assert user.goal_body_fat == "notfat"
+
+
+def test_repr():
+    user = User(
+        _id="000000000000000000000001",
+        username="user",
+        password="newPassword",
+        name="test user",
+        location="mars",
+        phone="1234567890",
+        body_type="big",
+        body_fat="fat",
+        height="7",
+        weight="100",
+        exp="12345",
+        goal_weight="95",
+        goal_body_fat="notfat",
+    )
+
+    assert repr(user) \
+        == "User(000000000000000000000001, user, newPassword, test user, mars, 1234567890, big, fat, 7, 100, 12345, 95, notfat)"
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/tests/test_workout.py b/tests/test_workout.py
new file mode 100644
index 0000000..f359101
--- /dev/null
+++ b/tests/test_workout.py
@@ -0,0 +1,62 @@
+import unittest
+from vitality.workout import Workout
+
+
+def test_as_dict():
+
+    workout = Workout(
+        _id="000000000000000000000001",
+        creator_id="000000000000000000000002",
+        name="Workout 1",
+        difficulty="easy",
+        about="An about section",
+        exp=123
+    )
+
+    new_dict = workout.as_dict()
+    comp_dict = dict(
+        _id="000000000000000000000001",
+        creator_id="000000000000000000000002",
+        name="Workout 1",
+        difficulty="easy",
+        about="An about section",
+        exp=123
+    )
+
+    assert new_dict == comp_dict
+
+
+def test_initalization():
+    workout = Workout(
+        _id="000000000000000000000001",
+        creator_id="000000000000000000000002",
+        name="Workout 1",
+        difficulty="easy",
+        about="An about section",
+        exp=123
+    )
+
+    assert workout._id == "000000000000000000000001"
+    assert workout.creator_id == "000000000000000000000002"
+    assert workout.name == "Workout 1"
+    assert workout.difficulty == "easy"
+    assert workout.about == "An about section"
+    assert workout.exp == 123
+
+
+def test_repr():
+    workout = Workout(
+        _id="000000000000000000000001",
+        creator_id="000000000000000000000002",
+        name="Workout 1",
+        difficulty="easy",
+        about="An about section",
+        exp=123
+    )
+
+    assert repr(workout) \
+        == "Workout(000000000000000000000001, 000000000000000000000002, Workout 1, easy, An about section, 123)"
+
+
+if __name__ == '__main__':
+    unittest.main()