def test_dont_write_pid_file_until_we_really_start(
self, mock_watchdog, mock_daemonize, mock_reactor):
"""
If the client can't be started because another client is still running,
the client shouldn't be daemonized and the pid file shouldn't be
written.
"""
mock_watchdog().check_running.return_value = succeed([StubDaemon()])
mock_reactor.crash.return_value = None
self.log_helper.ignore_errors(
"ERROR: The following daemons are already running: program-name")
pid_file = self.makeFile()
self.configuration.daemon = True
self.configuration.pid_file = pid_file
service = WatchDogService(self.configuration)
service.startService()
self.assertFalse(os.path.exists(pid_file))
mock_daemonize.assert_not_called()
mock_watchdog().check_running.assert_called_once_with()
mock_watchdog().start.assert_not_called()
mock_reactor.crash.assert_called_once_with()
评论列表
文章目录