Browse Source

[3028] Get rid of the print_settings command completely

It was used in tests only. We may abuse the shutdown command for that.
Michal 'vorner' Vaner 11 years ago
parent
commit
507da49470
2 changed files with 14 additions and 8 deletions
  1. 0 4
      src/bin/cmdctl/cmdctl.py.in
  2. 14 4
      src/bin/cmdctl/tests/cmdctl_test.py

+ 0 - 4
src/bin/cmdctl/cmdctl.py.in

@@ -370,10 +370,6 @@ class CommandControl():
             self._httpserver.shutdown()
             self._serving = False
 
-        elif command == 'print_settings':
-            # This is a hidden testing command. It does nothing useful, just
-            # returns the current configuration.
-            answer = ccsession.create_answer(0, self._cmdctl_config_data)
         else:
             answer = ccsession.create_answer(1, 'unknown command: ' + command)
 

+ 14 - 4
src/bin/cmdctl/tests/cmdctl_test.py

@@ -462,10 +462,20 @@ class TestCommandControl(unittest.TestCase):
         answer = self.cmdctl.command_handler('unknown-command', None)
         self._check_answer(answer, 1, 'unknown command: unknown-command')
 
-        answer = self.cmdctl.command_handler('print_settings', None)
+        # Send a real command. Mock stuff so the shutdown command doesn't
+        # cause an exception.
+        class ModuleCC:
+            def send_stopping():
+                pass
+        self.cmdctl._module_cc = ModuleCC
+        class Server:
+            def shutdown():
+                pass
+        self.cmdctl._httpserver = Server
+        answer = self.cmdctl.command_handler('shutdown', None)
         rcode, msg = ccsession.parse_answer(answer)
         self.assertEqual(rcode, 0)
-        self.assertTrue(msg != None)
+        self.assertIsNone(msg)
 
     def test_command_handler_spec_update(self):
         # Should not be present
@@ -543,10 +553,10 @@ class TestCommandControl(unittest.TestCase):
         self.assertEqual(1, rcode)
 
         # Send a command to cmdctl itself.  Should be the same effect.
-        rcode, value = self.cmdctl.send_command('Cmdctl', 'print_settings',
+        rcode, value = self.cmdctl.send_command('Cmdctl', 'shutdown',
                                                 None)
         self.assertEqual(2, len(self.cmdctl.sent_messages))
-        self.assertEqual(({'command': ['print_settings']}, 'Cmdctl'),
+        self.assertEqual(({'command': ['shutdown']}, 'Cmdctl'),
                          self.cmdctl.sent_messages[-1])
         self.assertEqual(1, rcode)