summaryrefslogtreecommitdiffstats
path: root/src/bin/shell
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2020-07-11 19:18:40 +0200
committerFrancis Dupont <fdupont@isc.org>2020-09-12 10:49:43 +0200
commitcb88a01789dfdd46ed280e8b074137ab3980f0b0 (patch)
treefc5faf63f249b3da4cd883742e47495842a53fe8 /src/bin/shell
parent[#1304] Fixed unicode handling (diff)
downloadkea-cb88a01789dfdd46ed280e8b074137ab3980f0b0.tar.xz
kea-cb88a01789dfdd46ed280e8b074137ab3980f0b0.zip
[#1304] Cosmetics
Diffstat (limited to 'src/bin/shell')
-rw-r--r--src/bin/shell/kea-shell.in10
-rw-r--r--src/bin/shell/tests/shell_process_tests.sh.in4
-rw-r--r--src/bin/shell/tests/shell_unittest.py.in29
3 files changed, 21 insertions, 22 deletions
diff --git a/src/bin/shell/kea-shell.in b/src/bin/shell/kea-shell.in
index 32125655c2..f229040857 100644
--- a/src/bin/shell/kea-shell.in
+++ b/src/bin/shell/kea-shell.in
@@ -17,7 +17,6 @@ Text client for Control Agent process
# that's a stand alone package that requires separate installation. One of
# the design requirements was to not require any additional packages, so
# the code uses standard libraries available in python. Hence two versions.
-import os
import sys
import signal
import argparse
@@ -30,8 +29,9 @@ from kea_conn import CARequest # CAResponse
if sys.version_info[0] == 2:
# This is Python 2.x
import kea_connector2 as kea_connector
- def auth8(s):
- return unicode(s, 'utf-8')
+ def auth8(string):
+ """Convert str into unicode"""
+ return unicode(string, 'utf-8')
elif sys.version_info[0] == 3:
# This is Python 3.x
import kea_connector3 as kea_connector
@@ -86,7 +86,7 @@ def shell_body():
if cmd_args.v:
print(VERSION)
- exit(0)
+ sys.exit(0)
# Ok, now it's time to put the parameters parsed into the structure to be
# used by the connection.
@@ -96,7 +96,7 @@ def shell_body():
params.http_host = cmd_args.host
params.http_port = cmd_args.port
params.path += cmd_args.path
- if cmd_args.auth_user is not '':
+ if cmd_args.auth_user != '':
user = cmd_args.auth_user
password = cmd_args.auth_password
secret = b':'.join((user.encode('utf-8'), password.encode('utf-8')))
diff --git a/src/bin/shell/tests/shell_process_tests.sh.in b/src/bin/shell/tests/shell_process_tests.sh.in
index a176ac0013..9b94868155 100644
--- a/src/bin/shell/tests/shell_process_tests.sh.in
+++ b/src/bin/shell/tests/shell_process_tests.sh.in
@@ -58,7 +58,7 @@ shell_command_test() {
# Log the start of the test and print test name.
test_start ${test_name}
-
+
# Remove any dangling CA instances and remove log files.
cleanup
@@ -100,7 +100,7 @@ shell_command_test() {
tmp="echo \"${params}\" | ${shell_bin_path}/${shell_bin} --host \
127.0.0.1 --port 8081 ${cmd} > ${tmpfile_path}/shell-stdout.txt"
echo "Executing kea-shell ($tmp)"
-
+
echo "${params}" | ${shell_bin_path}/${shell_bin} --host 127.0.0.1 \
--port 8081 ${cmd} > ${tmpfile_path}/shell-stdout.txt
diff --git a/src/bin/shell/tests/shell_unittest.py.in b/src/bin/shell/tests/shell_unittest.py.in
index b65b65c727..08a05f53dc 100644
--- a/src/bin/shell/tests/shell_unittest.py.in
+++ b/src/bin/shell/tests/shell_unittest.py.in
@@ -26,7 +26,6 @@ class CARequestUnitTest(unittest.TestCase):
"""
This method is called before each test. Currently it does nothing.
"""
- pass
def test_body_with_service(self):
"""
@@ -35,9 +34,10 @@ class CARequestUnitTest(unittest.TestCase):
"""
request = CARequest()
request.command = "foo"
- request.service= ["service1"]
+ request.service = ["service1"]
request.generate_body()
- self.assertEqual(request.content, '{ "command": "foo", "service": ["service1"] }')
+ self.assertEqual(request.content,
+ '{ "command": "foo", "service": ["service1"] }')
def test_body_with_multiple_service(self):
"""
@@ -46,9 +46,10 @@ class CARequestUnitTest(unittest.TestCase):
"""
request = CARequest()
request.command = "foo"
- request.service= ["service1","service2/2"]
+ request.service = ["service1", "service2/2"]
request.generate_body()
- self.assertEqual(request.content, '{ "command": "foo", "service": ["service1","service2/2"] }')
+ self.assertEqual(request.content,
+ '{ "command": "foo", "service": ["service1","service2/2"] }')
def test_body_with_malformed_service(self):
"""
@@ -57,9 +58,10 @@ class CARequestUnitTest(unittest.TestCase):
"""
request = CARequest()
request.command = "foo"
- request.service= ["service1",""]
+ request.service = ["service1", ""]
request.generate_body()
- self.assertEqual(request.content, '{ "command": "foo", "service": ["service1"] }')
+ self.assertEqual(request.content,
+ '{ "command": "foo", "service": ["service1"] }')
def test_body_without_args(self):
"""
@@ -92,14 +94,12 @@ class CARequestUnitTest(unittest.TestCase):
if header_name in headers:
if headers[header_name] == value:
return True
- else:
- print("Expected value: " + value +
- " does not match actual value: " +
- headers[header_name])
- return False
- else:
- print("Expected header: " + header_name + " missing")
+ print("Expected value: " + value +
+ " does not match actual value: " +
+ headers[header_name])
return False
+ print("Expected header: " + header_name + " missing")
+ return False
def test_headers(self):
"""
@@ -194,7 +194,6 @@ class CARequestUnitTest(unittest.TestCase):
"""
This method is called after each test. Currently it does nothing.
"""
- pass
if __name__ == '__main__':
unittest.main()