Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 def test_bundle_with_multiple(self):
     """
     L{Schema.bundle} correctly handles multiple arguments.
     """
     schema = Schema(Unicode("name.n"), Integer("count"))
     params = schema.bundle(name=["Foo", "Bar"], count=123)
     self.assertEqual({"name.1": "Foo", "name.2": "Bar", "count": "123"},
                      params)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 def test_bundle_with_multiple(self):
     """
     L{Schema.bundle} correctly handles multiple arguments.
     """
     schema = Schema(Unicode("name.n"), Integer("count"))
     params = schema.bundle(name=["Foo", "Bar"], count=123)
     self.assertEqual({"name.1": "Foo", "name.2": "Bar", "count": "123"},
                      params)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 def test_bundle_with_structure(self):
     """L{Schema.bundle} can bundle L{Structure}s."""
     schema = Schema(
         parameters=[
             Structure("struct", fields={"field1": Unicode(),
                                         "field2": Integer()})])
     params = schema.bundle(struct={"field1": "hi", "field2": 59})
     self.assertEqual({"struct.field1": "hi", "struct.field2": "59"},
                      params)
Ejemplo n.º 14
0
 def test_bundle_with_two_numbered(self):
     """
     L{Schema.bundle} can bundle multiple numbered lists.
     """
     schema = Schema(Unicode("names.n"), Unicode("things.n"))
     params = schema.bundle(names=["foo", "bar"], things=["baz", "quux"])
     self.assertEqual({"names.1": "foo", "names.2": "bar",
                       "things.1": "baz", "things.2": "quux"},
                      params)
Ejemplo n.º 15
0
    def test_bundle_with_arguments_and_extra(self):
        """
        L{Schema.bundle} can bundle L{Arguments} with keyword arguments too.

        Keyword arguments take precedence.
        """
        schema = Schema(Unicode("name.n"), Integer("count"))
        arguments = Arguments({"name": {1: "Foo", 7: "Bar"}, "count": 321})
        params = schema.bundle(arguments, count=123)
        self.assertEqual({"name.1": "Foo", "name.2": "Bar", "count": "123"},
                         params)
Ejemplo n.º 16
0
    def test_bundle_with_arguments_and_extra(self):
        """
        L{Schema.bundle} can bundle L{Arguments} with keyword arguments too.

        Keyword arguments take precedence.
        """
        schema = Schema(Unicode("name.n"), Integer("count"))
        arguments = Arguments({"name": {1: "Foo", 7: "Bar"}, "count": 321})
        params = schema.bundle(arguments, count=123)
        self.assertEqual({"name.1": "Foo", "name.2": "Bar", "count": "123"},
                         params)
Ejemplo n.º 17
0
 def test_bundle_with_two_numbered(self):
     """
     L{Schema.bundle} can bundle multiple numbered lists.
     """
     schema = Schema(Unicode("names.n"), Unicode("things.n"))
     params = schema.bundle(names=["foo", "bar"], things=["baz", "quux"])
     self.assertEqual(
         {
             "names.1": "foo",
             "names.2": "bar",
             "things.1": "baz",
             "things.2": "quux"
         }, params)
Ejemplo n.º 18
0
 def test_bundle_with_structure(self):
     """L{Schema.bundle} can bundle L{Structure}s."""
     schema = Schema(parameters=[
         Structure("struct",
                   fields={
                       "field1": Unicode(),
                       "field2": Integer()
                   })
     ])
     params = schema.bundle(struct={"field1": "hi", "field2": 59})
     self.assertEqual({
         "struct.field1": "hi",
         "struct.field2": "59"
     }, params)
Ejemplo n.º 19
0
 def test_bundle_with_list(self):
     """L{Schema.bundle} can bundle L{List}s."""
     schema = Schema(parameters=[List("things", item=Unicode())])
     params = schema.bundle(things=["foo", "bar"])
     self.assertEqual({"things.1": "foo", "things.2": "bar"}, params)
Ejemplo n.º 20
0
 def test_bundle_with_list(self):
     """L{Schema.bundle} can bundle L{List}s."""
     schema = Schema(parameters=[List("things", item=Unicode())])
     params = schema.bundle(things=["foo", "bar"])
     self.assertEqual({"things.1": "foo", "things.2": "bar"}, params)
Ejemplo n.º 21
0
 def test_bundle_with_none(self):
     """L{None} values are discarded in L{Schema.bundle}."""
     schema = Schema(Unicode("name.n", optional=True))
     params = schema.bundle(name=None)
     self.assertEqual({}, params)
Ejemplo n.º 22
0
 def test_bundle_with_none(self):
     """L{None} values are discarded in L{Schema.bundle}."""
     schema = Schema(Unicode("name.n", optional=True))
     params = schema.bundle(name=None)
     self.assertEqual({}, params)
Ejemplo n.º 23
0
 def test_bundle_with_list_with_arguments(self):
     """L{Schema.bundle} can bundle L{List}s (specified as L{Arguments})."""
     schema = Schema(parameters=[List("things", item=Unicode())])
     params = schema.bundle(things=Arguments({1: "foo", 2: "bar"}))
     self.assertEqual({"things.1": "foo", "things.2": "bar"}, params)
Ejemplo n.º 24
0
 def test_bundle_with_list_with_arguments(self):
     """L{Schema.bundle} can bundle L{List}s (specified as L{Arguments})."""
     schema = Schema(parameters=[List("things", item=Unicode())])
     params = schema.bundle(things=Arguments({1: "foo", 2: "bar"}))
     self.assertEqual({"things.1": "foo", "things.2": "bar"}, params)