本文整理汇总了Python中apidoc.object.source_raw.Version.types方法的典型用法代码示例。如果您正苦于以下问题:Python Version.types方法的具体用法?Python Version.types怎么用?Python Version.types使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apidoc.object.source_raw.Version
的用法示例。
在下文中一共展示了Version.types方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hydrate_type_changed
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_hydrate_type_changed(self):
root = Root()
version1 = Version()
version1.name = "v1"
version2 = Version()
version2.name = "v2"
type1 = Type()
type1.name = "m1"
type1.description = "b"
type1.item = ObjectString()
type2 = Type()
type2.name = "m1"
type2.description = "c"
type2.item = ObjectString()
root.versions = {"v1": version1, "v2": version2}
version1.types = {"m1": type1}
version2.types = {"m1": type2}
root_dto = RootDto()
Hydrator(version1, root.versions, []).hydrate_type(root_dto, root, type1)
Hydrator(version2, root.versions, []).hydrate_type(root_dto, root, type2)
self.assertEqual(1, len(root_dto.type_categories))
self.assertEqual(1, len(root_dto.type_categories[0].types))
self.assertEqual(2, len(root_dto.type_categories[0].types[0].description))
self.assertEqual(MultiVersion.Changes.updated, root_dto.type_categories[0].types[0].changes_status["v2"])
示例2: test_replace_type
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_replace_type(self):
root = Root()
version1 = Version()
method1 = Method()
object_type1 = ObjectType()
object_type1.type_name = "t1"
type1 = Type()
parameter1 = Parameter()
parameter1.type = "t1"
parameter2 = Parameter()
parameter2.type = "t1"
method1.request_body = object_type1
method1.request_parameters = {"p1": parameter1}
method1.request_headers = {"p1": parameter2}
version1.types = {"t1": type1}
version1.methods = {"m1": method1}
root.versions = {"v1": version1}
self.source.replace_types(root)
self.assertEqual(type1, method1.request_body.type_object)
self.assertEqual(type1, method1.request_parameters["p1"].type_object)
self.assertEqual(type1, method1.request_headers["p1"].type_object)
示例3: test_replace_references
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_replace_references(self):
root = Root()
version1 = Version()
method1 = Method()
type1 = Type()
object_reference1 = ObjectReference()
object_reference1.reference_name = "r1"
object_reference1.name = "a"
object_reference2 = ObjectReference()
object_reference2.reference_name = "r1"
object_reference2.name = "a"
object1 = ObjectObject()
object1.description = "b"
method1.request_body = object_reference1
type1.item = object_reference2
version1.references = {"r1": object1}
version1.methods = {"m1": method1}
version1.types = {"t1": type1}
root.versions = {"v1": version1}
self.source.replace_references(root)
self.assertEqual("a", method1.request_body.name)
self.assertEqual("b", method1.request_body.description)
self.assertEqual("a", type1.item.name)
self.assertEqual("b", type1.item.description)
示例4: test_get_uri_with_missing_parameters
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_get_uri_with_missing_parameters(self):
root = Root()
version = Version()
version.name = "v"
method = Method()
method.name = "m"
method.category = "a"
method.full_uri = "/{foo}/{p}"
parameter = Parameter()
parameter.name = "p"
parameter.type = "string"
method.request_parameters = {"p": parameter}
root.versions = {"v": version}
version.methods = {"m": method}
version.types = {"m": type}
root_dto = RootDto()
hydrator = Hydrator(version, {"v": version}, [])
hydrator.hydrate_method(root_dto, root, method)
parameters = self.source.validate(root_dto)
parameters = self.source.get_uri_with_missing_parameters(root_dto)
self.assertEqual([
{"name": "foo", "uri": "/{foo}/{p}", "method": "m", "version": "v"},
], parameters)
示例5: test_hydrate_type__with_known_category
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
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)
示例6: test_create_from_root
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_create_from_root(self):
root = Root()
version = Version()
version.name = "v"
method = Method()
method.category = "a"
type = Type()
type.category = "b"
type.item = ObjectString()
root.versions = {"v": version}
version.methods = {"m": method}
version.types = {"m": type}
response = self.factory.create_from_root(root)
self.assertIsInstance(response, RootDto)
self.assertEqual(1, len(response.method_categories))
self.assertEqual("a", response.method_categories[0].name)
self.assertEqual(1, len(response.method_categories[0].methods))
self.assertEqual(1, len(response.type_categories))
self.assertEqual("b", response.type_categories[0].name)
self.assertEqual(1, len(response.type_categories[0].types))
示例7: test_hydrate_method
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_hydrate_method(self):
root = Root()
version = Version()
version.name = "v"
method = Method()
method.category = "a"
method.full_uri = "/{p}/"
parameter = Parameter()
parameter.name = "p"
parameter.type = "string"
method.request_parameters = {"p": parameter}
root.versions = {"v": version}
version.methods = {"m": method}
version.types = {"m": type}
root_dto = RootDto()
hydrator = Hydrator(version, {"v": version}, [])
hydrator.hydrate_method(root_dto, root, method)
self.assertEqual(1, len(root_dto.method_categories))
self.assertEqual(0, len(root_dto.type_categories))
self.assertEqual(1, len(root_dto.method_categories[0].methods))
self.assertEqual(1, len(root_dto.method_categories[0].methods[0].request_parameters))
self.assertIsInstance(root_dto.method_categories[0].methods[0].request_parameters[0].value, RequestParameter)
self.assertEqual(1, root_dto.method_categories[0].methods[0].request_parameters[0].value.position)
示例8: test_hydrate_type__with_multiple_methds
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
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))
示例9: create_from_name_and_dictionary
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def create_from_name_and_dictionary(self, name, datas):
"""Return a populated object Version from dictionary datas
"""
version = ObjectVersion()
self.set_common_datas(version, name, datas)
if "uri" in datas:
version.uri = str(datas["uri"])
if "major" in datas:
version.major = int(datas["major"])
if "minor" in datas:
version.minor = int(datas["minor"])
if "status" in datas:
version.status = self.get_enum("status", ObjectVersion.Status, datas)
version.methods = self.method_factory.create_dictionary_of_element_from_dictionary("methods", datas)
version.types = self.type_factory.create_dictionary_of_element_from_dictionary("types", datas)
version.references = self.reference_factory.create_dictionary_of_element_from_dictionary("references", datas)
return version
示例10: test_hydrate_type
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
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))
示例11: test_hydrate_method__with_multiple_methds
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_hydrate_method__with_multiple_methds(self):
root = Root()
version = Version()
version.name = "v"
method1 = Method()
method1.category = "c"
method2 = Method()
method2.category = "c"
root.versions = {"v": version}
version.methods = {"m1": method1, "m2": method2}
version.types = {"m": type}
root_dto = RootDto()
hydrator = Hydrator(version, {"v": version}, [])
hydrator.hydrate_method(root_dto, root, method1)
hydrator.hydrate_method(root_dto, root, method2)
self.assertEqual(1, len(root_dto.method_categories))
示例12: test_remove_unused_types
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_remove_unused_types(self):
root = Root()
version1 = Version()
type1 = Type()
type2 = Type()
method1 = Method()
parameter1 = Parameter()
parameter1.type = "t1"
method1.request_parameters = {"p1": parameter1}
version1.types = {"t1": type1, "t2": type2}
version1.methods = {"m1": method1}
root.versions = {"v1": version1}
self.source.remove_unused_types(root)
self.assertEqual({"t1": type1}, version1.types)
示例13: test_hydrate_method__with_known_category
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import types [as 别名]
def test_hydrate_method__with_known_category(self):
root = Root()
version = Version()
version.name = "v"
method = Method()
method.category = "c"
root.versions = {"v": version}
version.methods = {"m": method}
version.types = {"m": type}
category = Category("c")
category.description = "d"
root.categories = {"c": category}
root_dto = RootDto()
hydrator = Hydrator(version, {"v": version}, [])
hydrator.hydrate_method(root_dto, root, method)
self.assertEqual("d", root_dto.method_categories[0].description)