예제 #1
0
    def test_invalid_request(self):
        """HTTPBadRequest should be raised if the data isn't a type we can render."""
        request = DummyRequest()

        text = renderers.rss(None)({}, {'request': request})

        assert text == 'Invalid RSS feed request'
        assert request.response.status_code == 400
예제 #2
0
 def test_invalid_caracters(self):
     request = DummyRequest()
     # Declare the routes on the testing config, otherwise req.route_url() won't work.
     self.config.include('cornice')
     self.config.scan('bodhi.server.services')
     comment = self.db.query(models.Comment).first()
     comment.text = "\x1b"
     try:
         output = renderers.rss(None)({"comments": [comment]}, {'request': request})
     except ValueError as e:
         assert False, e
     assert output.startswith(b"<?xml version='1.0' encoding='UTF-8'?>")
예제 #3
0
 def test_invalid_no_request(self):
     """HTTPBadRequest should be raised if data can't be rendered and there's no request."""
     with pytest.raises(HTTPBadRequest) as exc:
         renderers.rss(None)({}, {})
     assert str(exc.value) == 'Invalid RSS feed request'
예제 #4
0
    def test_invalid_no_request(self):
        """HTTPBadRequest should be raised if data can't be rendered and there's no request."""
        with self.assertRaises(HTTPBadRequest) as exc:
            renderers.rss(None)({}, {})

        self.assertEqual(str(exc.exception), 'Invalid RSS feed request')