Ejemplo n.º 1
0
 def test_decorator(self, passthrough_put, validate):
     decorator = xsd.validate("schema_path")
     func = mock.MagicMock()
     decorated = decorator(func)
     self.request = mock.MagicMock()
     self.request.body = "xml_body"
     validate.return_value = True
     decorated(self, "arg1")
     validate.assert_called_once_with("xml_body", "schema_path")
     func.assert_called_once_with(self, "arg1")
Ejemplo n.º 2
0
Archivo: xsd.py Proyecto: rkday/crest
 def test_decorator(self, passthrough_put, validate):
     decorator = xsd.validate("schema_path")
     func = mock.MagicMock()
     decorated = decorator(func)
     self.request = mock.MagicMock()
     self.request.body = "xml_body"
     validate.return_value = True
     decorated(self, "arg1")
     validate.assert_called_once_with("xml_body", "schema_path")
     func.assert_called_once_with(self, "arg1")
Ejemplo n.º 3
0
Archivo: xsd.py Proyecto: rkday/crest
 def test_decorator_error(self, passthrough_put, validate):
     decorator = xsd.validate("schema_path")
     func = mock.MagicMock()
     decorated = decorator(func)
     self.request = mock.MagicMock()
     self.request.body = "dodgy_xml_body"
     validate.side_effect = etree.XMLSyntaxError("XML Error", None, None, None)
     self.assertRaisesRegexp(HTTPError, "HTTP 400: Bad Request \(XML Error\)",
                             decorated,
                             self, "arg1")
     validate.assert_called_once_with("dodgy_xml_body", "schema_path")
     self.assertFalse(func.called)
Ejemplo n.º 4
0
 def test_decorator_error(self, passthrough_put, validate):
     decorator = xsd.validate("schema_path")
     func = mock.MagicMock()
     decorated = decorator(func)
     self.request = mock.MagicMock()
     self.request.body = "dodgy_xml_body"
     validate.side_effect = etree.XMLSyntaxError("XML Error", None, None, None)
     self.assertRaisesRegexp(HTTPError, "HTTP 400: Bad Request \(XML Error\)",
                             decorated,
                             self, "arg1")
     validate.assert_called_once_with("dodgy_xml_body", "schema_path")
     self.assertFalse(func.called)