-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tally_up.py
62 lines (56 loc) · 2.68 KB
/
test_tally_up.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
from tallyUpHours import tally_up
from extract import Talk
from hamcrest import assert_that, equal_to, contains_exactly
from datetime import timedelta, time
import re
def test_tally_empty_list():
scoreboard = tally_up([])
assert_that(scoreboard, equal_to({}))
def test_tally_one_talk():
scoreboard = tally_up([Talk(title='',
date=1,
time='',
duration=timedelta(hours=0, minutes=15),
place='',
speaker='',
language='',
fahrplan_url='',
translations=(),
translators=('one', 'two'))])
assert_that(scoreboard.keys(), contains_exactly('one', 'two'))
assert_that(scoreboard['one'][0], equal_to(timedelta(hours=0, minutes=15)))
def test_tally_multiple_talks():
scoreboard = tally_up([Talk(title='',
date=1,
time='',
duration=timedelta(hours=0, minutes=15),
place='',
speaker='',
language='',
fahrplan_url='',
translations=(),
translators=('one', 'two')),
Talk(title='',
date=1,
time='',
duration=timedelta(hours=1, minutes=0),
place='',
speaker='',
language='',
fahrplan_url='',
translations=(),
translators=('one', 'three')),
Talk(title='',
date=1,
time='',
duration=timedelta(hours=0, minutes=30),
place='',
speaker='',
language='',
fahrplan_url='',
translations=(),
translators=('two',))])
assert_that(scoreboard.keys(), contains_exactly('one', 'two', 'three'))
assert_that(scoreboard['one'][0], equal_to(timedelta(hours=1, minutes=15)))
assert_that(scoreboard['two'][0], equal_to(timedelta(hours=0, minutes=45)))
assert_that(scoreboard['three'][0], equal_to(timedelta(hours=1, minutes=00)))