-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_mail_utils.py
46 lines (33 loc) · 1.04 KB
/
test_mail_utils.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
import pytest
from mail_utils import assign_partner
emails = [
{
"name": "Rodolfo Ferro",
"email": "[email protected]"
},
{
"name": "Ricardo Mirón",
"email": "[email protected]"
},
{
"name": "Ivan Gonzalez",
"email": "[email protected]"
}
]
def _test_valid_emails(emails):
assigned = set()
for mail in emails:
assert mail.get('assigned', None) is not None # not empty assignment
assert mail['name'] != mail['assigned'] # no self assignment
assigned.add(mail['assigned'])
assert len(assigned) == len(emails) # all have assignment
def test_assign_partner():
global emails
with pytest.raises(ValueError):
assign_partner([])
with pytest.raises(ValueError):
assign_partner([0])
n = 10 # reasonable number of tests for a stochastic process
for _ in range(n):
assigned_emails = assign_partner(emails.copy())
_test_valid_emails(assigned_emails)