-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_utils.py
More file actions
33 lines (24 loc) · 844 Bytes
/
test_utils.py
File metadata and controls
33 lines (24 loc) · 844 Bytes
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
import pytest
import utils
def test_thing_to_surt_host_name():
tests = [
('va', 'va,'),
('va,', 'va,'),
('va,*', 'va,'),
('https://example.com/', 'com,example'),
('https://sub.example.com/', 'com,example,sub'),
('https://*.example.com/', 'com,example,'),
('*.example.com/', 'com,example,'),
#('.example.com/', 'com,example,'), # python's library drops that leading dot
('sub.example.com', 'com,example,sub'),
('*.sub.example.com', 'com,example,sub,'),
('example.com/foo', None),
]
value_error = [
('example.com,', ''),
]
for t1, t2 in tests:
assert utils.thing_to_surt_host_name(t1) == t2, t1
for t1, t2 in value_error:
with pytest.raises(ValueError):
utils.thing_to_surt_host_name(t1)