def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid', hostname='*****@*****.**') detached.assert_called_with( '/var/log', '/var/pid', None, None, None, None, False, after_forkers=False, ) execv.assert_called_with('/bin/boo', ['/bin/boo', 'a', 'b', 'c']) execv.side_effect = Exception('foo') r = detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid', hostname='*****@*****.**', app=self.app) context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with('ERROR', '/var/log', hostname='*****@*****.**') self.assertEqual(r, 1)
def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid') detached.assert_called_with( '/var/log', '/var/pid', None, None, None, None, False, after_forkers=False, ) execv.assert_called_with('/bin/boo', ['/bin/boo', 'a', 'b', 'c']) r = detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid', executable='/bin/foo', app=self.app) execv.assert_called_with('/bin/foo', ['/bin/foo', 'a', 'b', 'c']) execv.side_effect = Exception('foo') r = detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid', app=self.app) context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with('ERROR', '/var/log') self.assertEqual(r, 1) self.patch('celery.current_app') from celery import current_app r = detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid', app=None) current_app.log.setup_logging_subsystem.assert_called_with( 'ERROR', '/var/log', )
def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid") detached.assert_called_with("/var/log", "/var/pid", None, None, None, None, False, after_forkers=False) execv.assert_called_with("/bin/boo", ["/bin/boo", "a", "b", "c"]) r = detach( "/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid", executable="/bin/foo", app=self.app ) execv.assert_called_with("/bin/foo", ["/bin/foo", "a", "b", "c"]) execv.side_effect = Exception("foo") r = detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid", app=self.app) context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with("ERROR", "/var/log") self.assertEqual(r, 1) self.patch("celery.current_app") from celery import current_app r = detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid", app=None) current_app.log.setup_logging_subsystem.assert_called_with("ERROR", "/var/log")
def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid") detached.assert_called_with("/var/log", "/var/pid", None, None, None, None, False, after_forkers=False) execv.assert_called_with("/bin/boo", ["/bin/boo", "a", "b", "c"]) execv.side_effect = Exception("foo") r = detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid", app=self.app) context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with("ERROR", "/var/log") self.assertEqual(r, 1)
def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid') detached.assert_called_with('/var/log', '/var/pid', None, None, 0, None, False) execv.assert_called_with('/bin/boo', ['/bin/boo', 'a', 'b', 'c']) execv.side_effect = Exception('foo') r = detach('/bin/boo', ['a', 'b', 'c'], logfile='/var/log', pidfile='/var/pid') context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with('ERROR', '/var/log') self.assertEqual(r, 1)
def test_execs(self, setup_logs, logger, execv, detached): context = detached.return_value = Mock() context.__enter__ = Mock() context.__exit__ = Mock() detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid") detached.assert_called_with("/var/log", "/var/pid", None, None, 0, None, False) execv.assert_called_with("/bin/boo", ["/bin/boo", "a", "b", "c"]) execv.side_effect = Exception("foo") r = detach("/bin/boo", ["a", "b", "c"], logfile="/var/log", pidfile="/var/pid") context.__enter__.assert_called_with() self.assertTrue(logger.critical.called) setup_logs.assert_called_with("ERROR", "/var/log") self.assertEqual(r, 1)