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


Python Schema.extend方法代码示例

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


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

示例1: test_extend_errors

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
 def test_extend_errors(self):
     """
     Errors can be extended with L{Schema.extend}.
     """
     schema = Schema(parameters=[], errors=[APIError])
     schema2 = schema.extend(errors=[ZeroDivisionError])
     self.assertEqual(set([APIError, ZeroDivisionError]), schema2.errors)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:test_schema.py

示例2: test_extend_maintains_existing_attributes

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
    def test_extend_maintains_existing_attributes(self):
        """
        If additional schema attributes aren't passed to L{Schema.extend}, they
        stay the same.
        """
        result = {'id': Integer(), 'name': Unicode(), 'data': RawStr()}
        errors = [APIError]

        schema = Schema(
            name="GetStuff",
            doc="""Get the stuff.""",
            parameters=[Integer("id")],
            result=result,
            errors=errors)

        schema2 = schema.extend(parameters=[Unicode("scope")])

        self.assertEqual("GetStuff", schema2.name)
        self.assertEqual("Get the stuff.", schema2.doc)
        self.assertEqual(result, schema2.result)
        self.assertEqual(set(errors), schema2.errors)

        arguments, _ = schema2.extract({'id': '5', 'scope': u'foo'})
        self.assertEqual(5, arguments.id)
        self.assertEqual(u'foo', arguments.scope)
开发者ID:antisvin,项目名称:txAWS,代码行数:27,代码来源:test_schema.py

示例3: test_extend_with_additional_schema_attributes

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
    def test_extend_with_additional_schema_attributes(self):
        """
        The additional schema attributes can be passed to L{Schema.extend}.
        """
        result = {'id': Integer(), 'name': Unicode(), 'data': RawStr()}
        errors = [APIError]

        schema = Schema(
            name="GetStuff",
            parameters=[Integer("id")])

        schema2 = schema.extend(
            name="GetStuff2",
            doc="Get stuff 2",
            parameters=[Unicode("scope")],
            result=result,
            errors=errors)

        self.assertEqual("GetStuff2", schema2.name)
        self.assertEqual("Get stuff 2", schema2.doc)
        self.assertEqual(result, schema2.result)
        self.assertEqual(set(errors), schema2.errors)

        arguments, _ = schema2.extract({'id': '5', 'scope': u'foo'})
        self.assertEqual(5, arguments.id)
        self.assertEqual(u'foo', arguments.scope)
开发者ID:antisvin,项目名称:txAWS,代码行数:28,代码来源:test_schema.py

示例4: test_add_single_extra_schema_item

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
 def test_add_single_extra_schema_item(self):
     """New Parameters can be added to the Schema."""
     schema = Schema(Unicode("name"))
     schema = schema.extend(Unicode("computer"))
     arguments, _ = schema.extract({"name": "value", "computer": "testing"})
     self.assertEqual(u"value", arguments.name)
     self.assertEqual("testing", arguments.computer)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:test_schema.py

示例5: test_extend_maintains_parameter_order

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
 def test_extend_maintains_parameter_order(self):
     """
     Extending a schema with additional parameters puts the new parameters
     at the end.
     """
     schema = Schema(parameters=[Unicode("name"), Unicode("value")])
     schema2 = schema.extend(parameters=[Integer("foo"), Unicode("index")])
     self.assertEqual(["name", "value", "foo", "index"],
                      [p.name for p in schema2.get_parameters()])
开发者ID:antisvin,项目名称:txAWS,代码行数:11,代码来源:test_schema.py

示例6: test_add_extra_schema_items

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
 def test_add_extra_schema_items(self):
     """A list of new Parameters can be added to the Schema."""
     schema = Schema(Unicode("name"))
     schema = schema.extend(Unicode("computer"), Integer("count"))
     arguments, _ = schema.extract({"name": "value", "computer": "testing",
                                    "count": "5"})
     self.assertEqual(u"value", arguments.name)
     self.assertEqual("testing", arguments.computer)
     self.assertEqual(5, arguments.count)
开发者ID:antisvin,项目名称:txAWS,代码行数:11,代码来源:test_schema.py

示例7: test_extend_result

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extend [as 别名]
 def test_extend_result(self):
     """
     Result fields can also be extended with L{Schema.extend}.
     """
     schema = Schema(result={'name': Unicode()})
     schema2 = schema.extend(
         result={'id': Integer()})
     result_structure = Structure(fields=schema2.result)
     self.assertEqual(
         {'name': u'foo', 'id': 5},
         result_structure.coerce({'name': u'foo', 'id': '5'}))
开发者ID:antisvin,项目名称:txAWS,代码行数:13,代码来源:test_schema.py


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