2016-05-12 17:03:57 +00:00
|
|
|
# coding=utf-8
|
2016-05-29 11:33:20 +00:00
|
|
|
|
2015-09-05 16:15:47 +00:00
|
|
|
from netlib import utils, tutils
|
2015-04-29 21:04:22 +00:00
|
|
|
|
2016-05-29 11:33:20 +00:00
|
|
|
|
2016-07-20 22:38:37 +00:00
|
|
|
def test_is_valid_host():
|
|
|
|
assert not utils.is_valid_host(b"")
|
|
|
|
assert utils.is_valid_host(b"one.two")
|
|
|
|
assert not utils.is_valid_host(b"one"*255)
|
|
|
|
assert utils.is_valid_host(b"one.two.")
|
|
|
|
|
|
|
|
|
2015-04-29 21:04:22 +00:00
|
|
|
def test_bidi():
|
|
|
|
b = utils.BiDi(a=1, b=2)
|
|
|
|
assert b.a == 1
|
2015-04-30 00:10:08 +00:00
|
|
|
assert b.get_name(1) == "a"
|
|
|
|
assert b.get_name(5) is None
|
2015-04-29 21:04:22 +00:00
|
|
|
tutils.raises(AttributeError, getattr, b, "c")
|
2015-04-30 00:10:08 +00:00
|
|
|
tutils.raises(ValueError, utils.BiDi, one=1, two=1)
|