forked from python-validators/validators
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_domain.py
More file actions
35 lines (30 loc) · 778 Bytes
/
test_domain.py
File metadata and controls
35 lines (30 loc) · 778 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
34
35
# -*- coding: utf-8 -*-
import pytest
from validators import domain, ValidationFailure
@pytest.mark.parametrize('value', [
'example.com',
'xn----gtbspbbmkef.xn--p1ai',
'underscore_subdomain.example.com',
'something.versicherung',
'11.com',
'3.cn',
'a.cn',
'sub1.sub2.sample.co.uk',
'somerandomexample.xn--fiqs8s'
])
def test_returns_true_on_valid_domain(value):
assert domain(value)
@pytest.mark.parametrize('value', [
'example.com/',
'example.com:4444',
'example.-com',
'example.',
'-example.com',
'example-.com',
'_example.com',
'example_.com',
'example',
'a......b.com'
])
def test_returns_failed_validation_on_invalid_domain(value):
assert isinstance(domain(value), ValidationFailure)