Browse Source

[2641] Test that login_to_cmdctl() calls _have_users()

Mukund Sivaraman 12 years ago
parent
commit
0abfd1c9e1
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/bin/bindctl/tests/bindctl_test.py

+ 16 - 0
src/bin/bindctl/tests/bindctl_test.py

@@ -628,6 +628,22 @@ class TestConfigCommands(unittest.TestCase):
         finally:
             self.tool.conn = orig_conn
 
+    def test_login_to_cmdctl_calls_have_users(self):
+        # Test that login_to_cmdctl() calls _have_users() and fails if
+        # _have_users() returns False.
+        orig_have_users = self.tool._have_users
+        try:
+            def my_have_users():
+                return False
+
+            self.tool._have_users = my_have_users
+            self.assertFalse(self.tool.login_to_cmdctl())
+            self.__check_printed_messages(
+                ['There are no existing users. Please configure '
+                 'a user account using b10-cmdctl-usermgr.'])
+        finally:
+            self.tool._have_users = orig_have_users
+
     def test_run(self):
         def login_to_cmdctl():
             return True