def test_label(self): dp = DummyProcess.new_instance(inputs={'_label': 'My label'}) self.assertEquals(dp.calc.label, 'My label') dp.run_until_complete() with self.assertRaises(ValueError): DummyProcess.new_instance(inputs={'_label': 5})
def test_description(self): dp = DummyProcess.new_instance(inputs={'_description': 'My description'}) self.assertEquals(dp.calc.description, 'My description') dp.run_until_complete() with self.assertRaises(ValueError): DummyProcess.new_instance(inputs={'_description': 5})
def test_save_load(self): dp = DummyProcess.new_instance() # Create a bundle b = self.persistence.create_bundle(dp) # Save a bundle and reload it self.persistence.save(dp) b2 = self.persistence.load_checkpoint(dp.pid) # Now check that they are equal self.assertEqual(b, b2) dp.run_until_complete()
def test_calculation_input(self): @workfunction def simple_wf(): return {'a': Int(6), 'b': Int(7)} outputs, pid = run(simple_wf, _return_pid=True) calc = load_node(pid) dp = DummyProcess.new_instance(inputs={'calc': calc}) dp.run_until_complete() input_calc = dp.calc.get_inputs_dict()['calc'] self.assertTrue(isinstance(input_calc, FrozenDict)) self.assertEqual(input_calc['a'], outputs['a'])
def test_input_link_creation(self): dummy_inputs = ["1", "2", "3", "4"] inputs = {l: Int(l) for l in dummy_inputs} inputs['_store_provenance'] = True p = DummyProcess.new_instance(inputs) for label, value in p._calc.get_inputs_dict().iteritems(): self.assertTrue(label in inputs) self.assertEqual(int(label), int(value.value)) dummy_inputs.remove(label) # Make sure there are no other inputs self.assertFalse(dummy_inputs) p.stop() p.run_until_complete()
def test_none_input(self): # Check that if we pass no input the process runs fine DummyProcess.new_instance().run_until_complete() # Check that if we explicitly pass None as the input it also runs fine DummyProcess.new_instance(inputs=None).run_until_complete()
def test_pid_is_uuid(self): p = DummyProcess.new_instance(inputs={'_store_provenance': False}) self.assertEqual(uuid.UUID(p._calc.uuid), p.pid) p.stop() p.run_until_complete()
def test_inputs_template(self): inputs = DummyProcess.get_inputs_template() dp = DummyProcess.new_instance(inputs=inputs) dp.run_until_complete()