本文整理汇总了Python中apidoc.object.source_raw.Version类的典型用法代码示例。如果您正苦于以下问题:Python Version类的具体用法?Python Version怎么用?Python Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hydrate_type__with_known_category
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)
示例2: test_hydrate_method
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)
示例3: test_replace_references
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
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_create_from_root
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))
示例6: test_replace_type
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)
示例7: test_remove_hidden_elements
def test_remove_hidden_elements(self):
root = Root()
version1 = Version()
version2 = Version()
category1 = Category("c1")
category2 = Category("c2")
method1 = Method()
method2 = Method()
root.versions = {"v1": version1, "v2": version2}
root.categories = {"c1": category1, "c2": category2}
version1.methods = {"m1": method1, "m2": method2}
version2.methods = {"m1": method1, "m2": method2}
method1.category = "c1"
method2.category = "c2"
version1.display = False
category2.display = False
self.source.remove_hidden_elements(root)
self.assertEqual(1, len(root.versions))
self.assertEqual(version2, root.versions["v2"])
self.assertEqual(1, len(root.versions["v2"].methods))
self.assertEqual(method1, root.versions["v2"].methods["m1"])
示例8: test_hydrate_object
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)
示例9: test_define_changes_status__updated
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"])
示例10: test_define_changes_status
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"])
示例11: test_hydrate_value__none
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))
示例12: test_get_previous_version__unknown
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()
示例13: test_add_missing_categories
def test_add_missing_categories(self):
root = Root()
version1 = Version()
category1 = Category("c1")
method1 = Method()
method2 = Method()
root.versions = {"v1": version1}
root.categories = {"c1": category1}
version1.methods = {"m1": method1, "m2": method2}
method1.category = "c1"
method2.category = "c2"
self.source.add_missing_categories(root)
self.assertEqual(2, len(root.categories))
self.assertIsInstance(root.categories["c2"], Category)
示例14: test_hide_filtered_elements__category
def test_hide_filtered_elements__category(self):
root = Root()
version1 = Version()
category1 = Category("c")
category2 = Category("c")
category3 = Category("c")
category1.name = "v1"
category2.name = "v2"
category3.name = "v3"
root.versions = {"v1": version1}
version1.categories = {"s1": category1, "s2": category2, "s3": category3}
config = ConfigObject()
self.source.hide_filtered_elements(root, config["filter"])
self.assertTrue(category1.display)
self.assertTrue(category2.display)
self.assertTrue(category3.display)
示例15: test_hydrate_value
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)