-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_badge.py
More file actions
48 lines (39 loc) · 1.06 KB
/
test_badge.py
File metadata and controls
48 lines (39 loc) · 1.06 KB
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
import decimal
import pytest
from codecov import badge
@pytest.mark.parametrize(
'rate, expected',
[
(decimal.Decimal('10'), 'red'),
(decimal.Decimal('80'), 'orange'),
(decimal.Decimal('99'), 'brightgreen'),
],
)
def test_get_badge_color(rate, expected):
color = badge.get_badge_color(
rate=rate,
minimum_green=decimal.Decimal('90'),
minimum_orange=decimal.Decimal('60'),
)
assert color == expected
def test_get_static_badge_url():
result = badge.get_static_badge_url(label='a-b', message='c_d e', color='green')
assert result == 'https://img.shields.io/badge/a--b-c__d%20e-green.svg'
@pytest.mark.parametrize(
'label, message, color',
[
(
'Label',
'',
'brightgreen',
),
(
'Label',
'100% > 99%',
'',
),
],
)
def test_get_static_badge_url__error(label, message, color):
with pytest.raises(ValueError):
badge.get_static_badge_url(label=label, message=message, color=color)