-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_review.py
executable file
·53 lines (41 loc) · 1.4 KB
/
test_review.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
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3
"""Unittest module for the Review Class."""
import unittest
from datetime import datetime
import time
from models.review import Review
import re
import json
from models.engine.file_storage import FileStorage
import os
from models import storage
from models.base_model import BaseModel
class TestReview(unittest.TestCase):
"""Test Cases for the Review class."""
def setUp(self):
"""Sets up test methods."""
pass
def tearDown(self):
"""Tears down test methods."""
self.resetStorage()
pass
def resetStorage(self):
"""Resets FileStorage data."""
FileStorage._FileStorage__objects = {}
if os.path.isfile(FileStorage._FileStorage__file_path):
os.remove(FileStorage._FileStorage__file_path)
def test_8_instantiation(self):
"""Tests instantiation of Review class."""
b = Review()
self.assertEqual(str(type(b)), "<class 'models.review.Review'>")
self.assertIsInstance(b, Review)
self.assertTrue(issubclass(type(b), BaseModel))
def test_8_attributes(self):
"""Tests the attributes of Review class."""
attributes = storage.attributes()["Review"]
o = Review()
for k, v in attributes.items():
self.assertTrue(hasattr(o, k))
self.assertEqual(type(getattr(o, k, None)), v)
if __name__ == "__main__":
unittest.main()