-
Notifications
You must be signed in to change notification settings - Fork 75
/
test_team_organizer.py
81 lines (60 loc) · 2.17 KB
/
test_team_organizer.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
80
81
from team_organizer import Person, Organizer
import pytest
import random
import string
@pytest.fixture
def person():
''' Factory function that returns a function to get new Person '''
def rand_data_person():
name = ''.join(random.sample(string.ascii_lowercase, 3))
handle = '@' + name
lines = random.randint(0, 100000)
return Person(name, handle, lines)
return rand_data_person
@pytest.fixture
def organizer(person):
'''Uses the person fixture factory to create an organizer
and adds 4 persons to it.'''
org = Organizer()
for _ in range(4):
org.add(person())
return org
def test_add_person_with_higher_than_median(organizer):
median_lines = organizer.median_lines()
more_than_median_lines = median_lines + 1000
p = Person('a', '@a', more_than_median_lines)
organizer.add(p)
assert organizer.d[len(organizer.d) - 1] == p
@pytest.mark.skip(reason="broken test needs fixing")
def test_add_a_person_with_lower_than_median(organizer):
median_lines = organizer.median_lines()
less_than_median_lines = median_lines - 1000
p = Person('a', '@a', less_than_median_lines)
organizer.add(p)
assert 1/0 == 0
assert organizer.d[0] == p
pass
# Pytest Fixture: https://docs.pytest.org/en/latest/fixture.html
@pytest.mark.skip(reason="broken test needs fixing")
@pytest.mark.parametrize("test_input,expected", [
([Person('a', '@a', 1),
Person('b', '@b', 2),
Person('c', '@c', 3),
Person('d', '@d', 4)], 1),
([Person('a', '@a', 1)], 1)
])
def test_count_number_of_teams(organizer, test_input, expected):
for p in test_input:
organizer.add(p)
assert len(organizer.teams()) == expected
def test_add_a_person_who_has_never_written_code_before(organizer):
organizer.add(Person('a', '@a', 0))
pass
def test_add_two_person_with_same_name_but_different_slack_handles(organizer):
pass
def test_add_a_person_who_supplied_negative_lines_of_code(organizer):
'Behavior not implemented. Decide & implement the behavior & the test.'
pass
def test_add_same_person_twice():
'Behavior not implemented. Decide & implement the behavior & the test.'
pass