Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
9bd776e3
Commit
9bd776e3
authored
Nov 22, 2013
by
Mukund Sivaraman
Browse files
Merge branch 'trac3114'
parents
ae4a470f
9ad9193e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/python/isc/config/config_data.py
View file @
9bd776e3
...
...
@@ -24,6 +24,7 @@ import isc.cc.data
import
isc.config.module_spec
import
ast
import
copy
import
sys
class
ConfigDataError
(
Exception
):
pass
...
...
@@ -62,10 +63,16 @@ def check_type(spec_part, value):
else
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
"Incorrect specification part for type checking"
))
if
data_type
==
"integer"
and
type
(
value
)
!=
int
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is not an integer"
)
elif
data_type
==
"real"
and
type
(
value
)
!=
float
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is not a real"
)
if
data_type
==
"integer"
:
if
type
(
value
)
!=
int
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is not an integer"
)
if
value
>
sys
.
maxsize
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is too large an integer"
)
elif
data_type
==
"real"
:
if
type
(
value
)
!=
float
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is not a real"
)
if
float
(
value
)
>
sys
.
float_info
.
max
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is too large a float"
)
elif
data_type
==
"boolean"
and
type
(
value
)
!=
bool
:
raise
isc
.
cc
.
data
.
DataTypeError
(
str
(
value
)
+
" is not a boolean"
)
elif
data_type
==
"string"
and
type
(
value
)
!=
str
:
...
...
src/lib/python/isc/config/tests/config_data_test.py
View file @
9bd776e3
...
...
@@ -47,6 +47,7 @@ class TestConfigData(unittest.TestCase):
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
"a"
)
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
[
1
,
2
])
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
{
"a"
:
1
})
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
10000000000000000000000
)
spec_part
=
find_spec_part
(
config_spec
,
"value2"
)
check_type
(
spec_part
,
1.1
)
...
...
@@ -55,6 +56,7 @@ class TestConfigData(unittest.TestCase):
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
"a"
)
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
[
1
,
2
])
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
{
"a"
:
1
})
self
.
assertRaises
(
isc
.
cc
.
data
.
DataTypeError
,
check_type
,
spec_part
,
2.0000000e+308
)
spec_part
=
find_spec_part
(
config_spec
,
"value3"
)
check_type
(
spec_part
,
True
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment