def test_create(self): a = Float() # Check that initial value is zero self.assertAlmostEqual(a.value, 0.0) f = Float(6.0) self.assertAlmostEqual(f.value, 6.) self.assertAlmostEqual(f, Float(6.0)) i = Int() self.assertAlmostEqual(i.value, 0) i = Int(6) self.assertAlmostEqual(i.value, 6) self.assertAlmostEqual(f, i) b = Bool() self.assertAlmostEqual(b.value, False) b = Bool(False) self.assertAlmostEqual(b.value, False) self.assertAlmostEqual(b.value, get_false_node()) b = Bool(True) self.assertAlmostEqual(b.value, True) self.assertAlmostEqual(b.value, get_true_node()) s = Str() self.assertAlmostEqual(s.value, '') s = Str('Hello') self.assertAlmostEqual(s.value, 'Hello')
def test_create(self): """Creating basic data objects.""" term_a = Float() # Check that initial value is zero self.assertAlmostEqual(term_a.value, 0.0) float_ = Float(6.0) self.assertAlmostEqual(float_.value, 6.) self.assertAlmostEqual(float_, Float(6.0)) int_ = Int() self.assertAlmostEqual(int_.value, 0) int_ = Int(6) self.assertAlmostEqual(int_.value, 6) self.assertAlmostEqual(float_, int_) bool_ = Bool() self.assertAlmostEqual(bool_.value, False) bool_ = Bool(False) self.assertAlmostEqual(bool_.value, False) self.assertAlmostEqual(bool_.value, get_false_node()) bool_ = Bool(True) self.assertAlmostEqual(bool_.value, True) self.assertAlmostEqual(bool_.value, get_true_node()) str_ = Str() self.assertAlmostEqual(str_.value, '') str_ = Str('Hello') self.assertAlmostEqual(str_.value, 'Hello')
def test_launchers(self): """Verify that the various launchers are working.""" result = run(self.function_return_true) self.assertTrue(result) result, node = run_get_node(self.function_return_true) self.assertTrue(result) self.assertEqual(result, get_true_node()) self.assertTrue(isinstance(node, orm.CalcFunctionNode)) with self.assertRaises(AssertionError): submit(self.function_return_true)
def test_launchers(self): """Verify that the various launchers are working.""" result = run(self.function_return_true) self.assertTrue(result) result, node = run_get_node(self.function_return_true) self.assertTrue(result) self.assertEqual(result, get_true_node()) self.assertTrue(isinstance(node, orm.CalcFunctionNode)) # Process function can be submitted and will be run by a daemon worker as long as the function is importable # Note that the actual running is not tested here but is done so in `.github/system_tests/test_daemon.py`. node = submit(add_multiply, x=orm.Int(1), y=orm.Int(2), z=orm.Int(3)) assert isinstance(node, orm.WorkFunctionNode)
def function_return_true(): return get_true_node()