-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_amenity.py
40 lines (31 loc) · 1.17 KB
/
test_amenity.py
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
33
34
35
36
37
38
39
40
#!/usr/bin/python3
"""
Unittest for amenity.py
"""
import unittest
from models.amenity import Amenity
import datetime
class TestAmenity(unittest.TestCase):
"""Tests instances and methods from amenity class"""
a = Amenity()
def test_class_exists(self):
"""tests if class exists"""
res = "<class 'models.amenity.Amenity'>"
self.assertEqual(str(type(self.a)), res)
def test_user_inheritance(self):
"""test if Amenity is a subclass of BaseModel"""
self.assertIsInstance(self.a, Amenity)
def testHasAttributes(self):
"""verify if attributes exist"""
self.assertTrue(hasattr(self.a, 'name'))
self.assertTrue(hasattr(self.a, 'id'))
self.assertTrue(hasattr(self.a, 'created_at'))
self.assertTrue(hasattr(self.a, 'updated_at'))
def test_types(self):
"""tests if the type of the attribute is the correct one"""
self.assertIsInstance(self.a.name, str)
self.assertIsInstance(self.a.id, str)
self.assertIsInstance(self.a.created_at, datetime.datetime)
self.assertIsInstance(self.a.updated_at, datetime.datetime)
if __name__ == '__main__':
unittest.main()