# 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
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
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.
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')))
# Log the start of the test and print test name.
test_start ${test_name}
-
+
# Remove any dangling CA instances and remove log files.
cleanup
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
"""
This method is called before each test. Currently it does nothing.
"""
- pass
def test_body_with_service(self):
"""
"""
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):
"""
"""
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):
"""
"""
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):
"""
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):
"""
"""
This method is called after each test. Currently it does nothing.
"""
- pass
if __name__ == '__main__':
unittest.main()