def test_update_single_times(self): """ Test the update of time entries in a Process info dictionary. """ from supervisor.states import ProcessStates from supvisors.process import ProcessStatus # check times on a RUNNING process info info = any_process_info_by_state(ProcessStates.RUNNING) ProcessStatus.update_single_times(info, info['start'] + 10, 100) self.assertEqual(info['start'] + 10, info['now']) self.assertEqual(100, info['local_time']) self.assertEqual(10, info['uptime']) # check times on a STOPPED-like process info info = any_stopped_process_info() ProcessStatus.update_single_times(info, 10, 100) self.assertEqual(10, info['now']) self.assertEqual(100, info['local_time']) self.assertEqual(0, info['uptime'])
def test_create(self): """ Test the values set at construction. """ from supervisor.states import ProcessStates from supvisors.process import ProcessRules, ProcessStatus info = any_stopped_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) # check application default attributes self.assertIs(self.supvisors, process.supvisors) self.assertEqual(info['group'], process.application_name) self.assertEqual(info['name'], process.process_name) self.assertEqual(ProcessStates.UNKNOWN, process.state) self.assertTrue(process.expected_exit) self.assertEqual(0, process.last_event_time) self.assertEqual(set(), process.addresses) self.assertEqual({}, process.infos) self.assertEqual('', process.extra_args) self.assertFalse(process.ignore_wait_exit) # rules part self.assertDictEqual(ProcessRules(self.supvisors).__dict__, process.rules.__dict__)
def test_running(self): """ Test the running method. """ from supvisors.application import ApplicationStatus from supvisors.process import ProcessStatus application = ApplicationStatus('ApplicationTest', self.supvisors.logger) self.assertFalse(application.running()) # add a stopped process info = any_stopped_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) process.add_info('10.0.0.1', info) application.add_process(process) application.update_status() self.assertFalse(application.running()) # add a running process info = any_running_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) process.add_info('10.0.0.1', info) application.add_process(process) application.update_status() self.assertTrue(application.running())
def test_create(self): """ Test the values set at construction. """ from supervisor.states import ProcessStates from supvisors.process import ProcessRules, ProcessStatus info = any_stopped_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) # check application default attributes self.assertIs(self.supvisors, process.supvisors) self.assertEqual(info['group'], process.application_name) self.assertEqual(info['name'], process.process_name) self.assertEqual(ProcessStates.UNKNOWN, process.state) self.assertTrue(process.expected_exit) self.assertEqual(0, process.last_event_time) self.assertEqual(set(), process.addresses) self.assertEqual({}, process.infos) self.assertEqual('', process.extra_args) self.assertFalse(process.ignore_wait_exit) # rules part self.assertDictEqual( ProcessRules(self.supvisors).__dict__, process.rules.__dict__)
def test_stopped(self): """ Test the stopped method. """ from supvisors.application import ApplicationStatus from supvisors.process import ProcessStatus application = ApplicationStatus('ApplicationTest', self.supvisors.logger) self.assertTrue(application.stopped()) # add a stopped process info = any_stopped_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) process.add_info('10.0.0.1', info) application.add_process(process) application.update_status() self.assertTrue(application.stopped()) # add a running process info = any_running_process_info() process = ProcessStatus(info['group'], info['name'], self.supvisors) process.add_info('10.0.0.1', info) application.add_process(process) application.update_status() self.assertFalse(application.stopped())