本文整理汇总了Python中apidoc.object.source_raw.Version.name方法的典型用法代码示例。如果您正苦于以下问题:Python Version.name方法的具体用法?Python Version.name怎么用?Python Version.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apidoc.object.source_raw.Version
的用法示例。
在下文中一共展示了Version.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hydrate_method_changed
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_hydrate_method_changed(self):
root = Root()
version1 = Version()
version1.name = "v1"
version2 = Version()
version2.name = "v2"
method1 = Method()
method1.name = "m1"
method1.description = "b"
method2 = Method()
method2.name = "m1"
method2.description = "c"
root.versions = {"v1": version1, "v2": version2}
version1.methods = {"m1": method1}
version2.methods = {"m1": method2}
root_dto = RootDto()
Hydrator(version1, root.versions, []).hydrate_method(root_dto, root, method1)
Hydrator(version2, root.versions, []).hydrate_method(root_dto, root, method2)
self.assertEqual(1, len(root_dto.method_categories))
self.assertEqual(1, len(root_dto.method_categories[0].methods))
self.assertEqual(2, len(root_dto.method_categories[0].methods[0].description))
self.assertEqual(MultiVersion.Changes.updated, root_dto.method_categories[0].methods[0].changes_status["v2"])
示例2: test_define_changes_status
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_define_changes_status(self):
root_dto = RootDto()
version1 = Version()
version1.name = "v1"
version1.major = 1
version1 = VersionDto(version1)
version2 = Version()
version2.name = "v2"
version2.major = 2
version2 = VersionDto(version2)
category1 = MethodCategory(Category("c1"))
category2 = TypeCategory(Category("c2"))
method1 = Method()
method1.changes_status = {"v1": MultiVersion.Changes.none}
method2 = Method()
method2.changes_status = {"v1": MultiVersion.Changes.new}
method3 = Method()
method3.changes_status = {"v2": MultiVersion.Changes.new}
category1.methods = [method1, method2, method3]
root_dto.versions = [version1, version2]
root_dto.method_categories = [category1]
root_dto.type_categories = [category2]
self.factory.define_changes_status(root_dto)
self.assertEqual(MultiVersion.Changes.new, method1.changes_status["v1"])
self.assertEqual(MultiVersion.Changes.deleted, method2.changes_status["v2"])
self.assertEqual(MultiVersion.Changes.none, method3.changes_status["v1"])
示例3: test_define_changes_status__updated
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_define_changes_status__updated(self):
root_dto = RootDto()
version1 = Version()
version1.name = "v1"
version1.major = 1
version1 = VersionDto(version1)
version2 = Version()
version2.name = "v2"
version2.major = 2
version2 = VersionDto(version2)
category1 = MethodCategory(Category("c1"))
method1 = Method()
method1.changes_status = {"v1": MultiVersion.Changes.new, "v2": MultiVersion.Changes.updated}
category1.methods = [method1]
root_dto.versions = [version1, version2]
root_dto.method_categories = [category1]
self.factory.define_changes_status(root_dto)
self.assertEqual(MultiVersion.Changes.new, method1.changes_status["v1"])
self.assertEqual(MultiVersion.Changes.updated, method1.changes_status["v2"])
示例4: test_hydrate_type_changed
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [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"])
示例5: test_hydrate_object
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_hydrate_object(self):
version1 = Version()
version1.name = "v1"
version2 = Version()
version2.name = "v2"
versions = {"v1": version1, "v2": version2}
object_dto = []
object1 = ObjectObject()
object2 = ObjectObject()
object3 = ObjectObject()
object1.name = "a"
object2.name = "a"
object3.name = "b"
array = ObjectArray()
array.name = "b"
dynamic = ObjectDynamic()
dynamic.name = "c"
string = ObjectString()
string.name = "d"
type = ObjectType()
type.name = "e"
type.type_object = "f"
const = ObjectConst()
const.value = "g"
enum = ObjectEnum()
enum.name = "h"
enum.values = ["h"]
object1.properties = {"p1": array, "p3": const, "p4": enum}
object2.properties = {"p1": array, "p3": const, "p4": enum, "p2": type}
array.items = dynamic
dynamic.items = string
response = Hydrator(version1, versions, []).hydrate_object(object_dto, object1)
response = Hydrator(version2, versions, []).hydrate_object(object_dto, object2)
response = Hydrator(version1, versions, []).hydrate_object(object_dto, object3)
self.assertEqual(1, response)
self.assertEqual(2, len(object_dto))
self.assertIn(version1.name, object_dto[0].versions)
self.assertIn(version1.name, object_dto[0].versions)
self.assertNotIn(version2.name, object_dto[1].versions)
self.assertEqual("a", object_dto[0].value.name)
self.assertEqual("b", object_dto[0].value.properties["p1"][0].value.name)
self.assertEqual("c", object_dto[0].value.properties["p1"][0].value.items[0].value.name)
self.assertEqual("d", object_dto[0].value.properties["p1"][0].value.items[0].value.items[0].value.name)
self.assertEqual("e", object_dto[0].value.properties["p2"][0].value.name)
self.assertEqual("f", object_dto[0].value.properties["p2"][0].value.type_object)
self.assertEqual("g", object_dto[0].value.properties["p3"][0].value.value)
self.assertEqual("h", object_dto[0].value.properties["p4"][0].value.values[0].value)
示例6: test_get_previous_version__second
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_get_previous_version__second(self):
version1 = Version()
version1.name = "v1"
version1.major = 1
version2 = Version()
version2.name = "v2"
version2.major = 2
versions = {"v1": version1, "v2": version2}
response = Hydrator(version2, versions, []).get_previous_version()
self.assertEqual(version1, response)
示例7: test_get_previous_version__unknown
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_get_previous_version__unknown(self):
version1 = Version()
version1.name = "v1"
version1.major = 1
version2 = Version()
version2.name = "v2"
version2.major = 2
version3 = Version()
version3.name = "v3"
version3.major = 3
versions = {"v1": version1, "v2": version2}
with self.assertRaises(ValueError):
Hydrator(version3, versions, []).get_previous_version()
示例8: test_hydrate_value__none
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_hydrate_value__none(self):
version1 = Version()
version1.name = "v1"
version2 = Version()
version2.name = "v2"
versions = {"v1": version1, "v2": version2}
object_dto = []
object = None
response = Hydrator(version1, versions, []).hydrate_value(object_dto, object)
self.assertEqual(0, response)
self.assertEqual(0, len(object_dto))
示例9: test_hydrate_method
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [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)
示例10: test_hydrate_type__with_known_category
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [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)
示例11: test_create_from_root
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [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))
示例12: test_get_uri_with_missing_parameters
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [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)
示例13: test_hide_filtered_elements__version
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_hide_filtered_elements__version(self):
root = Root()
version1 = Version()
version2 = Version()
version3 = Version()
version1.name = "v1"
version2.name = "v2"
version3.name = "v3"
root.versions = {"v1": version1, "v2": version2, "v3": version3}
config = ConfigObject()
self.source.hide_filtered_elements(root, config["filter"])
self.assertTrue(version1.display)
self.assertTrue(version2.display)
self.assertTrue(version3.display)
示例14: test_hydrate_value
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_hydrate_value(self):
version1 = Version()
version1.name = "v1"
version2 = Version()
version2.name = "v2"
versions = {"v1": version1, "v2": version2}
object_dto = []
object = "a"
response = Hydrator(version1, versions, []).hydrate_value(object_dto, object)
response = Hydrator(version2, versions, []).hydrate_value(object_dto, object)
self.assertEqual(0, response)
self.assertEqual(1, len(object_dto))
self.assertEqual("a", object_dto[0].value)
self.assertIn(version1.name, object_dto[0].versions)
self.assertIn(version2.name, object_dto[0].versions)
示例15: test_version
# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import name [as 别名]
def test_version(self):
version = Version()
version.name = "a"
version.description = "b"
version.uri = "c"
version.major = 2
version.minor = 3
version.status = Version.Status.draft
version_dto = VersionDto(version)
self.assertEqual("a", version_dto.name)
self.assertEqual("b", version_dto.description)
self.assertEqual("c", version_dto.uri)
self.assertEqual(2, version_dto.major)
self.assertEqual(3, version_dto.minor)