class Vpn(Model): def __init__(self, id): self.id = id veth = Property(typ=str) veth_state = Property() links = Hash() chal = Property(typ=Model)
class User(Model): def __init__(self, id): self.id = id vlan = Property(typ=int) cn = Property(typ=str) status = Property() connections = Set(typ=Model)
class X(Model): def __init__(self, id): self.id = id one = Property(autocommit=False, typ=bytes) two = Property('2', typ=str) three = Property(alwaysfetch=True, typ=int) four = Property(autocommit=False, typ=float)
class Connection(Model): def __init__(self, addr): self.id = repr(addr) self.addr = addr addr = Property(typ=Address) alive = Property(typ=bool) user = Property(typ=Model) vpn = Property(typ=Model)
class Vpn(Model): LINK_UP = 'up' LINK_BRIDGED = 'bridged' LINK_DOWN = 'down' VETH_UP = 'up' VETH_DOWN = 'down' def __init__(self, id): self.id = id lock = Lock(timeout=30) veth = Property(typ=str) veth_state = Property(typ=str) chal = Property(typ=Model) links = Hash(typ=str)
class Cluster(Model): UP = 'up' EXPIRING = 'expiring' STOPPED = 'stopped' DOWN = 'down' def __init__(self, user, chal): self.id = '{}@{}'.format(user.id, chal.id) @property def project(self): return self.id.replace('@', '_', 1) lock = Lock(timeout=300) status = Property(typ=str) connections = Set(typ=Model) vpn = Property(typ=Model)
class X(Database): redis = canary prop = Property() collect = Set() class Mod(Model): pass
class X: redis = self.redis prop = Property("p", autocommit=True) key = "xkey"
class A: def __init__(self, redis=None, autocommit=False): self.redis = redis alpha = Property("abc", autocommit=False)
class X: redis = self.redis prop = Property("p") key = "xkey"
class X: prop = Property("p") key = "xkey"
class X: prop = Property("prop") key = None
def test_mangle(self): nameA, nameB = "fred", "wilma" self.assertNotEqual(Property.mangle(nameA), nameA) self.assertNotEqual(Property.mangle(nameA), Property.mangle(nameB))
class X: redis = self.redis prop = Property("p", alwaysfetch=False) key = "xkey"
class User(Model): def __init__(self, id): self.id = id vlan = Property(typ=int) cn = Property(typ=str)
class Cluster(Model): def __init__(self, user, chal): self.id = '{}!{}'.format(user.id, chal.id) status = Property(typ=str)