def test__entityclass__2(self): class X(object): @classmethod def __entityclass__(cls): return 'entityclass' self.assertEqual(functions_.entityclass(X), 'entityclass') self.assertEqual(functions_.entityclass(X()), 'entityclass')
def test__functions_1(self): dt = datatype_.DataType(DogEntity, DogTable, DogRecord, DogTuple, DogArray) self.assertIs(functions_.entityclass(dt), DogEntity) self.assertIs(functions_.tableclass(dt), DogTable) self.assertIs(functions_.recordclass(dt), DogRecord) self.assertIs(functions_.tupleclass(dt), DogTuple) self.assertIs(functions_.arrayclass(dt), DogArray)
def test__entityclass__1(self): dogs = Dogs() dog = DogRec(('Snoopy', 12), dogs) fld = record_.RecordFieldProxy(dog, 1) self.assertIs(fld.entityclass, Dog) self.assertIs(functions_.entityclass(fld), Dog)
def test__entityclass__1(self): with self.assertRaisesRegex(AttributeError, r'\b__entityclass__\b'): functions_.entityclass('foo')
def test__entityclass__2(self): class X(DogRec): pass X._entityclass = 'foo' self.assertIs(functions_.entityclass(X), X._entityclass)
def test__entityclass__1(self): klass = functions_.entityclass(DogRec) self.assertIs(klass, DogRec._entityclass)
def test__entityclass__1(self): self.assertIs(Dogs.entityclass, Dog) self.assertIs(Dogs.__entityclass__(), Dog) self.assertIs(Dogs().__entityclass__(), Dog) self.assertIs(functions_.entityclass(Dogs), Dog) self.assertIs(functions_.entityclass(Dogs()), Dog)
def test__entityclass__1(self): col = table_.TableColumnDescriptor(Dogs(), 1) self.assertIs(col.entityclass, Dog) self.assertIs(functions_.entityclass(col), Dog)