コード例 #1
0
ファイル: test_wsdl.py プロジェクト: GP89/txaws
 def test_append_with_too_many_items(self):
     """
     An error is raised when trying to append items above the max.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=0,
                max_occurs=1)
     root = etree.fromstring("<foo><item><bar>egg</bar></item></foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.append)
     self.assertEqual("Too many items in tag 'foo'", error.message)
     self.assertEqual(1, len(list(foo)))
コード例 #2
0
ファイル: test_wsdl.py プロジェクト: xzy3/txaws
 def test_append_with_too_many_items(self):
     """
     An error is raised when trying to append items above the max.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=0,
                max_occurs=1)
     root = etree.fromstring("<foo><item><bar>egg</bar></item></foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.append)
     self.assertEqual("Too many items in tag 'foo'", error.args[0])
     self.assertEqual(1, len(list(foo)))
コード例 #3
0
ファイル: test_wsdl.py プロジェクト: GP89/txaws
 def test_delitem_with_not_enough_items(self):
     """
     L{SequenceItem.__delitem__} raises an error if trying to remove an item
     would make the sequence shorter than the required minimum.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=1,
                max_occurs=10)
     root = etree.fromstring("<foo><item><bar>egg</bar></item></foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.__delitem__, 0)
     self.assertEqual("Not enough items in tag 'foo'", error.message)
     self.assertEqual(1, len(list(foo)))
コード例 #4
0
ファイル: test_wsdl.py プロジェクト: xzy3/txaws
 def test_delitem_with_not_enough_items(self):
     """
     L{SequenceItem.__delitem__} raises an error if trying to remove an item
     would make the sequence shorter than the required minimum.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=1,
                max_occurs=10)
     root = etree.fromstring("<foo><item><bar>egg</bar></item></foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.__delitem__, 0)
     self.assertEqual("Not enough items in tag 'foo'", error.args[0])
     self.assertEqual(1, len(list(foo)))
コード例 #5
0
ファイル: test_wsdl.py プロジェクト: GP89/txaws
 def test_get_with_index_higher_than_max(self):
     """
     An error is raised when trying to access an item above the allowed
     max value.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=0,
                max_occurs=1)
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.__getitem__, 1)
     self.assertEqual("Out of range item in tag 'foo'", error.message)
コード例 #6
0
ファイル: test_wsdl.py プロジェクト: xzy3/txaws
 def test_get_with_index_higher_than_max(self):
     """
     An error is raised when trying to access an item above the allowed
     max value.
     """
     schema = SequenceSchema("foo")
     schema.set(NodeSchema("item", [LeafSchema("bar")]), min_occurs=0,
                max_occurs=1)
     root = etree.fromstring("<foo>"
                             "<item><bar>egg0</bar></item>"
                             "<item><bar>egg1</bar></item>"
                             "</foo>")
     foo = schema.create(root)
     error = self.assertRaises(WSDLParseError, foo.__getitem__, 1)
     self.assertEqual("Out of range item in tag 'foo'", error.args[0])