def test_restart_should_warn_when_starting_failed(self):
        import xmlrpclib
        rpc = Mock()
        rpc.supervisor.startProcess.side_effect = xmlrpclib.Fault(13, 'failed')
        uptimemon = Uptimemon({}, {}, rpc)

        uptimemon.restart('process')
        self.assertEquals(self.log[0]['msg'], 'Restarting %s')
        self.assertEquals(self.log[1]['msg'], 'Failed to start process %s after stopping it: %s')
 def test_should_not_restart_if_process_uptime_not_defined(self):
     uptimemon = Uptimemon({}, {}, Mock())
     uptimemon.restart = Mock()
     uptimemon.check_process_info(
         name='foo',
         group='group',
         now=1700,
         start=1000,
         statename='RUNNING')
     assert not uptimemon.restart.called
 def test_check_process_info_should_not_restart_not_running(self):
     uptimemon = Uptimemon({'group:foo':600}, {}, Mock())
     uptimemon.restart = Mock()
     uptimemon.check_process_info(
         name='foo',
         group='group',
         now=1700,
         start=1000,
         statename='STOPPED')
     assert not uptimemon.restart.called
 def test_check_process_info_should_restart_processes_by_full_name(self):
     uptimemon = Uptimemon({'group:foo':600}, {}, Mock())
     uptimemon.restart = Mock()
     uptimemon.check_process_info(
         name='foo',
         group='group',
         now=1700,
         start=1000,
         statename='RUNNING')
     uptimemon.restart.assert_called_with('group:foo')
     assert self.log[0]['msg'] == 'Process %s is running since %i seconds, longer than allowed %i'