def test_tendril_defs(): t1 = ecto.Tendril() t2 = ecto.Tendril() t1.val = 10 t1.notify() t1 = t2 assert t2.val == t1.val t2.val = 13 t2.notify() assert t1.val == 13 print t1.doc print t1.type_name print t1.val print t1.get() t1.set("foo") t1.notify() print t1.val assert t2.val == t1.val
def test_cpp_python_tendril(): x = ecto.Tendril.createT('int') x.val = 10 x.notify() t1 = ecto.Tendril() #this connection should force the t1 to become a native type. t1 = x t1.val = 20 t1.notify() assert t1.type_name == x.type_name assert x.val == 20
def test_tendril(): print "here" tendril = ecto.Tendril() tendril.set(5) t = ecto.Tendril() t.val = 5 #t.notify() #tendril.notify() assert t.val == t.get() assert t.val == 5 assert tendril.val == t.val assert tendril.get() == 5 assert tendril.get() == t.get() tendril.val = 10 t.val = tendril.val t.val = "hi" t.notify() assert tendril.val != "hi" assert t.val == t.get() assert t.val == "hi"
def test_python_serialization(): y = ecto.Tendril(None) #empty tendril x = ecto.Tendril.createT('std::string') x.val = 'UuUuU' y.load(x.save()) assert y.type_name == 'std::string' assert y.val == x.val print y.val sy = y.save() print len(sy) print len(y.val) import binhex print binhex.binascii.hexlify(sy)
def configure(self, p, i, o): self._dealer = ecto.Dealer(tendril=ecto.Tendril(Document()), iterable=p.db_models)
#!/usr/bin/env python import ecto import ecto.ecto_test as ecto_test for type_name in ecto.Tendril.listT(): t = ecto.Tendril.createT(type_name) print t.type_name, ' Value (', try: print t.val, except TypeError as e: print '*NA*', print ')' str_t = ecto.Tendril.createT('std::string') str_t.val = "foobar" str_t_dest = ecto.Tendril() str_t_dest.copy_value(str_t) assert str_t_dest.val == 'foobar' try: no = ecto.Tendril.createT('doesntexist::Foo') assert False and "shouldn't reach here!" except ecto.TypeMismatch as e: print "Good, threw:", e