-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_profile.py
49 lines (38 loc) · 1.36 KB
/
test_profile.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
from os import error
import unittest
import profile
import sqlite3
import db
class TestProfile(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
db.clear()
db.init_db()
@classmethod
def tearDownClass(cls) -> None:
db.clear()
def test_get_profile_input_invalid(self):
conn = None
try:
conn = sqlite3.connect('sqlite_db')
cur = conn.cursor()
mock_data_sql = 'INSERT OR IGNORE INTO USER ' +\
'(email, password, name, ' +\
'zipcode, rating, \
transaction_count, phone_number) ' +\
'VALUES (\'[email protected]\', \'123\', \'rick\', \
100000, 5, 1, \'123123\');'
print(mock_data_sql)
cur.execute(mock_data_sql)
conn.commit()
print('Database Online, a mock user has been inserted.')
test_res = profile.get_profile("[email protected]")
exp_res = '{"profile": {"email": "[email protected]", ' +\
'"name": "rick", "zipcode": 100000, ' +\
'"phone_number": "123123"}}'
self.assertEqual(exp_res, test_res)
except error as e:
print(e)
finally:
if conn:
conn.close()