def test_pid(self): # Test auto generation of pid p = DummyProcessWithOutput.new() self.assertIsNotNone(p.pid) # Test using integer as pid p = DummyProcessWithOutput.new(pid=5) self.assertEquals(p.pid, 5) # Test using string as pid p = DummyProcessWithOutput.new(pid='a') self.assertEquals(p.pid, 'a')
def setUp(self): super(TestProcess, self).setUp() self.events_tester = ProcessListenerTester() self.proc = DummyProcessWithOutput.new() self.proc.add_process_listener(self.events_tester) self.executor = ThreadExecutor()
def test_run(self): p = DummyProcessWithOutput.new() p.play() self.assertTrue(p.has_finished()) self.assertEqual(p.state, ProcessState.STOPPED) self.assertEqual(p.outputs, {'default': 5})
def test_created_bundle(self): """ Check that the bundle after just creating a process is as we expect :return: """ proc = DummyProcessWithOutput.new() b = Bundle() proc.save_instance_state(b) self.assertIsNone(b.get('inputs', None)) self.assertEqual(len(b['outputs']), 0)
def test_instance_state(self): proc = DummyProcessWithOutput.new() saver = ProcessSaver(proc) proc.play() for info, outputs in zip(saver.snapshots, saver.outputs): state, bundle = info # Check that it is a copy self.assertIsNot( outputs, bundle[Process.BundleKeys.OUTPUTS.value].get_dict()) # Check the contents are the same self.assertEqual( outputs, bundle[Process.BundleKeys.OUTPUTS.value].get_dict()) self.assertIsNot( proc.outputs, saver.snapshots[-1][1][Process.BundleKeys.OUTPUTS.value])
def test_run_from_class(self): # Test running through class method results = DummyProcessWithOutput.run() self.assertEqual(results['default'], 5)
def setUp(self): super(TestWaitingProcess, self).setUp() self.events_tester = ProcessListenerTester() self.proc = DummyProcessWithOutput.new() self.proc.add_process_listener(self.events_tester)