-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_models.py
54 lines (39 loc) · 1.25 KB
/
test_models.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
import pytest
from slack_invite_flow import models
def build_user(first, last):
return {first: {
'first': first,
'last': last,
'email': '{}.{}@gmail.com'.format(first, last)
}}
def test_user_load():
user = models.User.load(build_user('john', 'doe'))
assert ['john', 'doe', '[email protected]'] == [
user.first,
user.last,
user.email
]
def test_user_load_exception():
user = {}
with pytest.raises(models.ConfigurationException):
models.User.load(user)
def test_manager_load():
users = models.UserManager.load([
build_user('john', 'doe'),
build_user('jane', 'smith'),
build_user('foo', 'bar'),
build_user('gee', 'see'),
])
assert [
['john', 'john', 'doe', '[email protected]'],
['jane', 'jane', 'smith', '[email protected]'],
['foo', 'foo', 'bar', '[email protected]'],
['gee', 'gee', 'see', '[email protected]']] == users.as_table
def test_manager_first_names():
users = models.UserManager.load([
build_user('john', 'doe'),
build_user('jane', 'smith'),
build_user('foo', 'bar'),
build_user('gee', 'see'),
])
assert 'john, jane, foo and gee' == users.first_names