Example #1
0
    def test__ensure_console_pid_dir_exists(self, mock_path_exists,
                                            mock_makedirs):
        mock_path_exists.return_value = True
        mock_makedirs.side_effect = OSError
        pid_dir = console_utils._get_console_pid_dir()

        console_utils._ensure_console_pid_dir_exists()

        mock_path_exists.assert_called_once_with(pid_dir)
        self.assertFalse(mock_makedirs.called)
Example #2
0
    def test__ensure_console_pid_dir_exists(self, mock_path_exists,
                                            mock_makedirs):
        mock_path_exists.return_value = True
        mock_makedirs.side_effect = OSError
        pid_dir = console_utils._get_console_pid_dir()

        console_utils._ensure_console_pid_dir_exists()

        mock_path_exists.assert_called_once_with(pid_dir)
        self.assertFalse(mock_makedirs.called)
Example #3
0
    def test__ensure_console_pid_dir_exists_fail(self, mock_path_exists,
                                                 mock_makedirs):
        mock_path_exists.return_value = False
        mock_makedirs.side_effect = OSError
        pid_dir = console_utils._get_console_pid_dir()

        self.assertRaises(exception.ConsoleError,
                          console_utils._ensure_console_pid_dir_exists)

        mock_path_exists.assert_called_once_with(pid_dir)
        mock_makedirs.assert_called_once_with(pid_dir)
Example #4
0
    def test__ensure_console_pid_dir_exists_fail(self, mock_path_exists,
                                                 mock_makedirs):
        mock_path_exists.return_value = False
        mock_makedirs.side_effect = OSError
        pid_dir = console_utils._get_console_pid_dir()

        self.assertRaises(exception.ConsoleError,
                          console_utils._ensure_console_pid_dir_exists)

        mock_path_exists.assert_called_once_with(pid_dir)
        mock_makedirs.assert_called_once_with(pid_dir)
Example #5
0
 def test__get_console_pid_dir_tempdir(self):
     self.config(tempdir='/tmp/fake_dir')
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(CONF.tempdir, dir)
Example #6
0
 def test__get_console_pid_dir(self):
     pid_dir = '/tmp/pid_dir'
     self.config(terminal_pid_dir=pid_dir, group='console')
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(pid_dir, dir)
Example #7
0
 def test__get_console_pid_dir_tempdir(self):
     tempdir = tempfile.gettempdir()
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(tempdir, dir)
Example #8
0
 def test__get_console_pid_dir(self):
     pid_dir = '/tmp/pid_dir'
     self.config(terminal_pid_dir=pid_dir, group='console')
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(pid_dir, dir)
Example #9
0
 def test__get_console_pid_dir_tempdir(self):
     self.config(tempdir='/tmp/fake_dir')
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(CONF.tempdir, dir)