Skip to content
GitLab
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
61b0d4c3
Commit
61b0d4c3
authored
Mar 08, 2017
by
Tomek Mrugalski
🛰
Browse files
[5137] Tests rearranged, proper version is now reported in HTTP headers
parent
357a7ea3
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/shell/kea-shell.py
View file @
61b0d4c3
...
...
@@ -55,6 +55,7 @@ params.command = cmd_args.command
params
.
http_host
=
cmd_args
.
host
params
.
http_port
=
cmd_args
.
port
params
.
timeout
=
cmd_args
.
timeout
params
.
version
=
VERSION
params
.
generateBody
()
params
.
generateHeaders
()
...
...
src/bin/shell/kea_conn.py
View file @
61b0d4c3
...
...
@@ -10,6 +10,7 @@
# - command - specifies the command to send (e.g. list-commands)
# - timeout - timeout (in ms)
# - headers - extra HTTP headers may be added here
# - version - version to be reported in HTTP header
class
CARequest
:
path
=
'/'
http_host
=
''
...
...
@@ -18,6 +19,7 @@ class CARequest:
timeout
=
0
params
=
''
headers
=
{}
version
=
""
# Generates the content, out of specified command line
# and optional content.
...
...
@@ -34,7 +36,7 @@ class CARequest:
# In particular, this method generates Content-Length and its value.
def
generateHeaders
(
self
):
self
.
headers
[
'Content-Type'
]
=
'application/json'
self
.
headers
[
'User-Agent'
]
=
'
Kea-shell/
0.1'
self
.
headers
[
'User-Agent'
]
=
"
Kea-shell/
%s"
%
(
self
.
version
)
self
.
headers
[
'Accept'
]
=
'*/*'
self
.
headers
[
'Content-Length'
]
=
"%d"
%
(
len
(
self
.
content
))
...
...
src/bin/shell/tests/Makefile.am
View file @
61b0d4c3
PYTESTS
=
kea-
shell_unittest.py
PYTESTS
=
shell_unittest.py
SHTESTS
=
shell_process_tests.sh
...
...
@@ -6,16 +6,16 @@ noinst_SCRIPTS = $(PYTESTS) shell_process_tests.sh
EXTRA_DIST
=
testdata/plugins/testplugin.py
# test using command-line arguments, so use check-local target instead of TESTS
check-local
:
check-
local-
shell check-
local-
python
check-local
:
check-shell check-python
check-
local-
python
:
check-python
:
@
for
pytest
in
$(PYTESTS)
;
do
\
echo
Running python
test
:
$$
pytest
;
\
chmod
+x
$(abs_builddir)
/
$$
pytest
;
\
PYTHONPATH
=
$(PYTHONPATH)
:
$(abs_top_builddir)
/src/bin/shell python
$(abs_builddir)
/
$$
pytest
||
exit
;
\
done
check-
local-
shell
:
check-shell
:
@
for
shtest
in
$(SHTESTS)
;
do
\
echo
Running shell
test
:
$$
shtest
;
\
export
KEA_LOCKFILE_DIR
=
$(abs_top_builddir)
;
\
...
...
src/bin/shell/tests/
kea-
shell_unittest.py
→
src/bin/shell/tests/shell_unittest.py
View file @
61b0d4c3
...
...
@@ -84,6 +84,15 @@ class CARequestUnitTest(unittest.TestCase):
self
.
assertTrue
(
self
.
checkHeader
(
x
.
headers
,
'Content-Length'
,
str
(
len
(
x
.
content
))))
def
test_headerVersion
(
self
):
"""
This test checks if the version reported in HTTP headers is generated properly.
"""
x
=
CARequest
()
x
.
version
=
"1.2.3"
x
.
generateHeaders
()
self
.
assertTrue
(
self
.
checkHeader
(
x
.
headers
,
'User-Agent'
,
'Kea-shell/1.2.3'
))
def
tearDown
(
self
):
"""
This method is called after each test. Currently it does nothing.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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