blob: 49576b4f43e7d606922a0927844644cc205f33bb (
plain)
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
|
diff --git a/tests/test_validate.py b/tests/test_validate.py
index bffb0dc..c7d57d3 100644
--- a/tests/test_validate.py
+++ b/tests/test_validate.py
@@ -2,7 +2,7 @@
from configobj import ConfigObj
import pytest
-from validate import Validator, VdtValueTooSmallError
+from validate import Validator, VdtValueTooSmallError, dottedQuadToNum
class TestBasic(object):
@@ -161,3 +161,26 @@ class TestBasic(object):
'test3': 3,
'test4': 6.0
}}}
+
+
+class TestDottedQuadToNum(object):
+
+ def test_stripped(self):
+ assert dottedQuadToNum('192.0.2.0') == 3221225984
+ assert dottedQuadToNum('192.0.2.1 ') == 3221225985
+ assert dottedQuadToNum(' 192.0.2.2') == 3221225986
+ assert dottedQuadToNum('\t\t192.0.2.3\n') == 3221225987
+ with pytest.raises(ValueError) as excinfo:
+ dottedQuadToNum('192. 0. 2. 4')
+ assert str(excinfo.value) == 'Not a good dotted-quad IP: 192. 0. 2. 4'
+
+ def test_boundaries(self):
+ assert dottedQuadToNum('0.0.0.0') == 0
+ assert dottedQuadToNum('255.255.255.255') == 4294967295
+ with pytest.raises(ValueError) as excinfo:
+ dottedQuadToNum('255.255.255.256')
+ assert str(excinfo.value) == (
+ 'Not a good dotted-quad IP: 255.255.255.256')
+ with pytest.raises(ValueError) as excinfo:
+ dottedQuadToNum('-1')
+ assert str(excinfo.value) == 'Not a good dotted-quad IP: -1'
|