-
Notifications
You must be signed in to change notification settings - Fork 184
/
update_quality_test.py
103 lines (89 loc) · 3.23 KB
/
update_quality_test.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import pytest
from award import Award
from update_quality import update_quality
@pytest.mark.parametrize("initial_expires_in,initial_quality,expected_quality",
[
(5,10,9),
(0,10,8),
(-10,10,8),
(5,0,0),
])
def test_normal_award(initial_expires_in, initial_quality, expected_quality):
award = Award(name = 'NORMAL ITEM', expires_in = initial_expires_in, quality
= initial_quality)
update_quality([award])
assert award.expires_in == initial_expires_in - 1
assert award.quality == expected_quality
@pytest.mark.parametrize("initial_expires_in,initial_quality,expected_quality",
[
(5,10,11),
(5,50,50),
(0,10,12),
(0,49,50),
(0,50,50),
(-10,10,12),
(-10,50,50),
])
def test_blue_first(initial_expires_in, initial_quality, expected_quality):
award = Award(name = 'Blue First', expires_in = initial_expires_in, quality
= initial_quality)
update_quality([award])
assert award.expires_in == initial_expires_in - 1
assert award.quality == expected_quality
@pytest.mark.parametrize("initial_expires_in,initial_quality,expected_quality",
[
(5,80,80),
(0,80,80),
(-10,80,80),
])
def test_blue_distinction(initial_expires_in, initial_quality,
expected_quality):
award = Award(name = 'Blue Distinction Plus', expires_in =
initial_expires_in, quality = initial_quality)
update_quality([award])
assert award.expires_in == initial_expires_in
assert award.quality == expected_quality
@pytest.mark.parametrize("initial_expires_in,initial_quality,expected_quality",
[
(11,10,11),
(10,10,12),
(10,50,50),
(6,10,12),
(6,50,50),
(5,10,13),
(5,50,50),
(1,10,13),
(1,50,50),
(0,10,0),
(-10,10,0),
])
def test_blue_compare(initial_expires_in, initial_quality, expected_quality):
award = Award(name = 'Blue Compare', expires_in = initial_expires_in,
quality = initial_quality)
update_quality([award])
assert award.expires_in == initial_expires_in - 1
assert award.quality == expected_quality
@pytest.mark.parametrize("initial_expires_in,initial_quality,expected_quality",
[
(5,10,8),
(5,0,0),
(0,10,6),
(0,0,0),
(-10,10,6),
(-10,0,0),
])
@pytest.mark.xfail(reason = 'Pending')
def test_blue_star(initial_expires_in, initial_quality, expected_quality):
award = Award(name = 'Blue Star', expires_in = initial_expires_in,
quality = initial_quality)
update_quality([award])
assert award.expires_in == initial_expires_in - 1
assert award.quality == expected_quality
def test_several_awards():
award1 = Award(name = 'NORMAL ITEM', expires_in = 5, quality = 10)
award2 = Award(name = 'Blue First', expires_in = 3, quality = 10)
update_quality([award1, award2])
assert award1.quality == 9
assert award1.expires_in == 4
assert award2.quality == 11
assert award2.expires_in == 2