示例#1
0
    def test_pid(self):
        # Test auto generation of pid
        process = test_utils.DummyProcessWithOutput()
        self.assertIsNotNone(process.pid)

        # Test using integer as pid
        process = test_utils.DummyProcessWithOutput(pid=5)
        self.assertEqual(process.pid, 5)

        # Test using string as pid
        process = test_utils.DummyProcessWithOutput(pid='a')
        self.assertEqual(process.pid, 'a')
示例#2
0
    def test_execute(self):
        proc = test_utils.DummyProcessWithOutput()
        proc.execute()

        self.assertTrue(proc.done())
        self.assertEqual(proc.state, ProcessState.FINISHED)
        self.assertEqual(proc.outputs, {'default': 5})
示例#3
0
    def test_continue(self):
        """ Test continuing a saved process """
        process = test_utils.DummyProcessWithOutput()
        self.persister.save_checkpoint(process)
        pid = process.pid
        del process

        # Let the process run to the end
        result = yield self.process_controller.continue_process(pid)
        self.assertEqual(result, test_utils.DummyProcessWithOutput.EXPECTED_OUTPUTS)
示例#4
0
    def test_instance_state_with_outputs(self):
        proc = test_utils.DummyProcessWithOutput()

        saver = test_utils.ProcessSaver(proc)
        proc.execute()

        self._check_round_trip(proc)

        for bundle, outputs in zip(saver.snapshots, saver.outputs):
            # Check that it is a copy
            self.assertIsNot(outputs, bundle.get(BundleKeys.OUTPUTS, {}))
            # Check the contents are the same
            self.assertDictEqual(outputs, bundle.get(BundleKeys.OUTPUTS, {}))

        self.assertIsNot(proc.outputs,
                         saver.snapshots[-1].get(BundleKeys.OUTPUTS, {}))
示例#5
0
 def setUp(self):
     super(TestProcessEvents, self).setUp()
     self.proc = test_utils.DummyProcessWithOutput()
示例#6
0
 def test_run_from_class(self):
     # Test running through class method
     proc = test_utils.DummyProcessWithOutput()
     proc.execute()
     results = proc.outputs
     self.assertEqual(results['default'], 5)