]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1304] Cosmetics
authorFrancis Dupont <fdupont@isc.org>
Sat, 11 Jul 2020 17:18:40 +0000 (19:18 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 12 Sep 2020 08:49:43 +0000 (10:49 +0200)
src/bin/shell/kea-shell.in
src/bin/shell/tests/shell_process_tests.sh.in
src/bin/shell/tests/shell_unittest.py.in

index 32125655c22b9614e835fbfa00ba94cd638b5aab..f229040857f56f76149c2cdff6815165e2931445 100644 (file)
@@ -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')))
index a176ac001355a8f3cef364373ba56f2def7ef638..9b9486815528b8feebff6586491d49dc2b1c209a 100644 (file)
@@ -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
 
index b65b65c7278376f9ae8bb1dcd5968b88e5ab31f9..08a05f53dc7bbb852e9b9734eb62a2477659e478 100644 (file)
@@ -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()