-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
79 lines (49 loc) · 1.69 KB
/
tests.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
from userdb import sessions
def test_create_session():
sid = sessions.create()
assert type(sid) == str
def test_get_session():
sid = sessions.create()
data = sessions.get(sid)
assert data == {}
def test_get_attribute():
sid = sessions.create()
data = sessions.get(sid)
data['br'] = {'123': '10/05/2016'}
assert sessions.update(sid, data)
data = sessions.get(sid)
assert data['br']['123'] == '10/05/2016'
value = sessions.get_attribute(sid, 'br')
assert value['123'] == '10/05/2016'
value = sessions.get_attribute(sid, 'ar')
assert value is None
def test_update_session():
sid = sessions.create()
data = sessions.get(sid)
data['br'] = {'123': '10/05/2016'}
assert sessions.update(sid, data)
data = sessions.get(sid)
assert data['br']['123'] == '10/05/2016'
data['br'] = {'123': '11/05/2016'}
assert sessions.update(sid, data)
data = sessions.get(sid)
assert data['br']['123'] == '11/05/2016'
def test_update_attribute():
sid = sessions.create()
assert sessions.update_attribute(sid, 'br', {'123': '10/05/2016'})
value = sessions.get_attribute(sid, 'br')
assert value['123'] == '10/05/2016'
assert sessions.update_attribute(sid, 'br', {'123': '11/05/2016'})
value = sessions.get_attribute(sid, 'br')
assert value['123'] == '11/05/2016'
def test_delete_session():
sid = sessions.create()
data = sessions.get(sid)
data['br'] = {'123': '10/05/2016'}
assert sessions.update(sid, data)
data = sessions.get(sid)
assert data['br']['123'] == '10/05/2016'
assert sessions.destroy(sid)
data = sessions.get(sid)
assert data == {}