def test_hydrate_type__with_known_category(self): root = Root() version = Version() version.name = "v" type = Type() type.category = "c" type.item = ObjectString() root.versions = {"v": version} version.types = {"m": type} version.types = {"m": type} category = Category("c") category.description = "d" root.categories = {"c": category} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type) self.assertEqual("d", root_dto.type_categories[0].description)
def test_hydrate_type__with_known_category(self): root = Root() version = Version() version.name = "v" type = Type() type.category = "c" type.item = ObjectString() root.versions = {"v": version} version.types = {"m": type} version.types = {"m": type} category = Category("c") category.description = "d" root.categories = {"c": category} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type) self.assertEqual("d", root_dto.type_categories[0].description)
def test_hydrate_type(self): root = Root() version = Version() version.name = "v" type = Type() type.category = "a" type.item = ObjectString() root.versions = {"v": version} version.types = {"m": type} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type) self.assertEqual(0, len(root_dto.method_categories)) self.assertEqual(1, len(root_dto.type_categories)) self.assertEqual(1, len(root_dto.type_categories[0].types))
def test_hydrate_type(self): root = Root() version = Version() version.name = "v" type = Type() type.category = "a" type.item = ObjectString() root.versions = {"v": version} version.types = {"m": type} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type) self.assertEqual(0, len(root_dto.method_categories)) self.assertEqual(1, len(root_dto.type_categories)) self.assertEqual(1, len(root_dto.type_categories[0].types))
def test_hydrate_type__with_multiple_methds(self): root = Root() version = Version() version.name = "v" type1 = Type() type1.category = "c" type1.item = ObjectString() type2 = Type() type2.category = "c" type2.item = ObjectString() root.versions = {"v": version} version.types = {"m1": type1, "m2": type2} version.types = {"m": type} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type1) hydrator.hydrate_type(root_dto, root, type2) self.assertEqual(1, len(root_dto.type_categories))
def test_hydrate_type__with_multiple_methds(self): root = Root() version = Version() version.name = "v" type1 = Type() type1.category = "c" type1.item = ObjectString() type2 = Type() type2.category = "c" type2.item = ObjectString() root.versions = {"v": version} version.types = {"m1": type1, "m2": type2} version.types = {"m": type} root_dto = RootDto() hydrator = Hydrator(version, {"v": version}, []) hydrator.hydrate_type(root_dto, root, type1) hydrator.hydrate_type(root_dto, root, type2) self.assertEqual(1, len(root_dto.type_categories))