• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python schema.Schema类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_optional_list

 def test_optional_list(self):
     """
     The default value of an optional L{List} is C{[]}.
     """
     schema = Schema(List("names", Unicode(), optional=True))
     arguments, _ = schema.extract({})
     self.assertEqual([], arguments.names)
开发者ID:antisvin,项目名称:txAWS,代码行数:7,代码来源:test_schema.py


示例2: test_extract_with_single_numbered

 def test_extract_with_single_numbered(self):
     """
     L{Schema.extract} can handle a single parameter with a numbered value.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name.0": "Joe"})
     self.assertEqual("Joe", arguments.name[0])
开发者ID:ArtRichards,项目名称:txaws,代码行数:7,代码来源:test_schema.py


示例3: test_add_single_extra_schema_item

 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,代码行数:7,代码来源:test_schema.py


示例4: test_bundle_with_numbered

 def test_bundle_with_numbered(self):
     """
     L{Schema.bundle} correctly handles numbered arguments.
     """
     schema = Schema(Unicode("name.n"))
     params = schema.bundle(name=["foo", "bar"])
     self.assertEqual({"name.1": "foo", "name.2": "bar"}, params)
开发者ID:antisvin,项目名称:txAWS,代码行数:7,代码来源:test_schema.py


示例5: test_bundle_with_empty_numbered

 def test_bundle_with_empty_numbered(self):
     """
     L{Schema.bundle} correctly handles an empty numbered arguments list.
     """
     schema = Schema(Unicode("name.n"))
     params = schema.bundle(name=[])
     self.assertEqual({}, params)
开发者ID:antisvin,项目名称:txAWS,代码行数:7,代码来源:test_schema.py


示例6: test_extend_with_additional_schema_attributes

    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,代码行数:26,代码来源:test_schema.py


示例7: test_bundle_with_numbered_not_supplied

 def test_bundle_with_numbered_not_supplied(self):
     """
     L{Schema.bundle} ignores parameters that are not present.
     """
     schema = Schema(Unicode("name.n"))
     params = schema.bundle()
     self.assertEqual({}, params)
开发者ID:antisvin,项目名称:txAWS,代码行数:7,代码来源:test_schema.py


示例8: test_extract_complex

    def test_extract_complex(self):
        """L{Schema} can cope with complex schemas."""
        schema = Schema(
            Unicode("GroupName"),
            RawStr("IpPermissions.n.IpProtocol"),
            Integer("IpPermissions.n.FromPort"),
            Integer("IpPermissions.n.ToPort"),
            Unicode("IpPermissions.n.Groups.m.UserId", optional=True),
            Unicode("IpPermissions.n.Groups.m.GroupName", optional=True))

        arguments, _ = schema.extract(
            {"GroupName": "Foo",
             "IpPermissions.1.IpProtocol": "tcp",
             "IpPermissions.1.FromPort": "1234",
             "IpPermissions.1.ToPort": "5678",
             "IpPermissions.1.Groups.1.GroupName": "Bar",
             "IpPermissions.1.Groups.2.GroupName": "Egg"})

        self.assertEqual(u"Foo", arguments.GroupName)
        self.assertEqual(1, len(arguments.IpPermissions))
        self.assertEqual(1234, arguments.IpPermissions[0].FromPort)
        self.assertEqual(5678, arguments.IpPermissions[0].ToPort)
        self.assertEqual(2, len(arguments.IpPermissions[0].Groups))
        self.assertEqual("Bar", arguments.IpPermissions[0].Groups[0].GroupName)
        self.assertEqual("Egg", arguments.IpPermissions[0].Groups[1].GroupName)
开发者ID:antisvin,项目名称:txAWS,代码行数:25,代码来源:test_schema.py


示例9: test_extend_maintains_existing_attributes

    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,代码行数:25,代码来源:test_schema.py


示例10: test_schema_conversion_optional_list

 def test_schema_conversion_optional_list(self):
     """
     Backwards-compatibility conversions maintains optional-ness of lists.
     """
     schema = Schema(Unicode("foos.N", optional=True))
     arguments, _ = schema.extract({})
     self.assertEqual([], arguments.foos)
开发者ID:antisvin,项目名称:txAWS,代码行数:7,代码来源:test_schema.py


示例11: test_extend_errors

 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,代码行数:7,代码来源:test_schema.py


示例12: test_default_list

 def test_default_list(self):
     """
     The default of a L{List} can be specified as a list.
     """
     schema = Schema(List("names", Unicode(), optional=True,
                          default=[u"foo", u"bar"]))
     arguments, _ = schema.extract({})
     self.assertEqual([u"foo", u"bar"], arguments.names)
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例13: test_bundle_with_arguments

 def test_bundle_with_arguments(self):
     """L{Schema.bundle} can bundle L{Arguments} too."""
     schema = Schema(Unicode("name.n"), Integer("count"))
     arguments = Arguments({"name": Arguments({1: "Foo", 7: "Bar"}),
                            "count": 123})
     params = schema.bundle(arguments)
     self.assertEqual({"name.1": "Foo", "name.7": "Bar", "count": "123"},
                      params)
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例14: test_extract_with_mixed

 def test_extract_with_mixed(self):
     """
     L{Schema.extract} stores in the rest result all numbered parameters
     given without an index.
     """
     schema = Schema(Unicode("name.n"))
     _, rest = schema.extract({"name": "foo", "name.1": "bar"})
     self.assertEqual(rest, {"name": "foo"})
开发者ID:ArtRichards,项目名称:txaws,代码行数:8,代码来源:test_schema.py


示例15: test_extract_with_rest

 def test_extract_with_rest(self):
     """
     L{Schema.extract} stores unknown parameters in the 'rest' return
     dictionary.
     """
     schema = Schema()
     _, rest = schema.extract({"name": "value"})
     self.assertEqual(rest, {"name": "value"})
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例16: test_extract_with_non_numbered_template

 def test_extract_with_non_numbered_template(self):
     """
     L{Schema.extract} accepts a single numbered argument even if the
     associated template is not numbered.
     """
     schema = Schema(Unicode("name"))
     arguments, _ = schema.extract({"name.1": "foo"})
     self.assertEqual("foo", arguments.name)
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例17: test_extract_with_single_numbered

 def test_extract_with_single_numbered(self):
     """
     L{Schema.extract} can handle an un-numbered argument passed in to a
     numbered parameter.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name": "Joe"})
     self.assertEqual("Joe", arguments.name[0])
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例18: test_extract_with_numbered

 def test_extract_with_numbered(self):
     """
     L{Schema.extract} can handle parameters with numbered values.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name.0": "Joe", "name.1": "Tom"})
     self.assertEqual("Joe", arguments.name[0])
     self.assertEqual("Tom", arguments.name[1])
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例19: test_extract_structure_with_optional

 def test_extract_structure_with_optional(self):
     """L{Schema.extract} can handle optional parameters."""
     schema = Schema(
         Structure(
             "struct",
             fields={"name": Unicode(optional=True, default="radix")}))
     arguments, _ = schema.extract({"struct": {}})
     self.assertEqual(u"radix", arguments.struct.name)
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py


示例20: test_bundle

 def test_bundle(self):
     """
     L{Schema.bundle} returns a dictionary of raw parameters that
     can be used for an EC2-style query.
     """
     schema = Schema(Unicode("name"))
     params = schema.bundle(name="foo")
     self.assertEqual({"name": "foo"}, params)
开发者ID:antisvin,项目名称:txAWS,代码行数:8,代码来源:test_schema.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python service.AWSServiceEndpoint类代码示例发布时间:2022-05-27
下一篇:
Python client.Query类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap