Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 7
0
 def test__get_console_pid_dir_tempdir(self):
     tempdir = tempfile.gettempdir()
     dir = console_utils._get_console_pid_dir()
     self.assertEqual(tempdir, dir)
Esempio n. 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)
Esempio n. 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)