Example #1
0
 def test_component_start_stop_internal(self):
     """
     Test the behavior of _stop_internal and _start_internal.
     """
     component = Component('component', self, 'needed', 'Address')
     component.start()
     self.assertTrue(component.is_running())
     self.assertEqual('component', self.__start_simple_params)
     component.pid = lambda: 42
     component.stop()
     self.assertFalse(component.is_running())
     self.assertEqual(('component', 'Address', 42),
                      self.__stop_process_params)
Example #2
0
 def test_component_attributes(self):
     """
     Test the default attributes of Component (not BaseComponent) and
     some of the methods we might be allowed to call.
     """
     class TestProcInfo:
         def __init__(self):
             self.pid = 42
     component = Component('component', self, 'needed', 'Address',
                           ['hello'], TestProcInfo)
     self.assertEqual('component', component._process)
     self.assertEqual('component', component.name())
     self.assertIsNone(component._procinfo)
     self.assertIsNone(component.pid())
     self.assertEqual(['hello'], component._params)
     self.assertEqual('Address', component._address)
     self.assertFalse(component.is_running())
     self.assertEqual({}, self.__registered_processes)
     component.start()
     self.assertTrue(component.is_running())
     # Some versions of unittest miss assertIsInstance
     self.assertTrue(isinstance(component._procinfo, TestProcInfo))
     self.assertEqual(42, component.pid())
     self.assertEqual(component, self.__registered_processes.get(42))