当前位置: 首页>>代码示例>>Python>>正文


Python Version.methods方法代码示例

本文整理汇总了Python中apidoc.object.source_raw.Version.methods方法的典型用法代码示例。如果您正苦于以下问题:Python Version.methods方法的具体用法?Python Version.methods怎么用?Python Version.methods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apidoc.object.source_raw.Version的用法示例。


在下文中一共展示了Version.methods方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_hydrate_method_changed

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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"])
开发者ID:bahamut1221,项目名称:apidoc,代码行数:29,代码来源:test_rootDto.py

示例2: test_remove_hidden_elements

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [as 别名]
    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"])
开发者ID:MartinThoma,项目名称:apidoc,代码行数:29,代码来源:test_source.py

示例3: test_replace_type

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:MartinThoma,项目名称:apidoc,代码行数:34,代码来源:test_source.py

示例4: test_replace_references

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:MartinThoma,项目名称:apidoc,代码行数:36,代码来源:test_source.py

示例5: test_get_uri_with_missing_parameters

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:MartinThoma,项目名称:apidoc,代码行数:31,代码来源:test_source.py

示例6: test_create_from_root

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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))
开发者ID:bahamut1221,项目名称:apidoc,代码行数:27,代码来源:test_rootDto.py

示例7: test_hydrate_method

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:bahamut1221,项目名称:apidoc,代码行数:32,代码来源:test_rootDto.py

示例8: test_add_missing_categories

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [as 别名]
    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)
开发者ID:MartinThoma,项目名称:apidoc,代码行数:21,代码来源:test_source.py

示例9: create_from_name_and_dictionary

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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
开发者ID:MartinThoma,项目名称:apidoc,代码行数:22,代码来源:version.py

示例10: test_hydrate_method__with_multiple_methds

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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))
开发者ID:bahamut1221,项目名称:apidoc,代码行数:24,代码来源:test_rootDto.py

示例11: test_remove_unused_types

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:MartinThoma,项目名称:apidoc,代码行数:25,代码来源:test_source.py

示例12: test_hydrate_method__with_known_category

# 需要导入模块: from apidoc.object.source_raw import Version [as 别名]
# 或者: from apidoc.object.source_raw.Version import methods [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)
开发者ID:bahamut1221,项目名称:apidoc,代码行数:26,代码来源:test_rootDto.py


注:本文中的apidoc.object.source_raw.Version.methods方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。