File: test_domain.py

package info (click to toggle)
validators 0.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 332 kB
  • sloc: python: 1,556; makefile: 150
file content (42 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
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
# -*- 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',
    'someThing.versicherung',
    '11.com',
    '3.cn',
    'a.cn',
    'sub1.sub2.sample.co.uk',
    'somerandomexample.xn--fiqs8s',
    'kräuter.com',
    'über.com'
])
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',
    'a.123',
    '123.123',
    '123.123.123',
    '123.123.123.123'
])
def test_returns_failed_validation_on_invalid_domain(value):
    assert isinstance(domain(value), ValidationFailure)