示例#1
0
 def test_env_cleared(self):
     app = middleware.AutoMimeMiddleware(FakeApp(), {})
     req = Request.blank('/v1/a/c/obj.txt',
                         environ={
                             'REQUEST_METHOD': 'PUT',
                             'CONTENT_TYPE': 'something'
                         })
     res = req.get_response(app)
     self.assertEqual(res.environ.get('CONTENT_TYPE'), None)
     self.assertEqual(res.status_int, 200)
示例#2
0
 def test_unknown_type_encoding(self):
     app = middleware.AutoMimeMiddleware(FakeApp(), {})
     req = Request.blank('/v1/a/c/obj.bla',
                         environ={
                             'REQUEST_METHOD': 'PUT',
                             'swift.cache': self.cache
                         })
     res = req.get_response(app)
     self.assertFalse(res.environ.get('HTTP_CONTENT_TYPE', False))
     self.assertFalse(res.environ.get('HTTP_CONTENT_ENCODING', False))
     self.assertEqual(res.status_int, 200)
示例#3
0
 def test_set_type_and_encoding(self):
     app = middleware.AutoMimeMiddleware(FakeApp(), {})
     req = Request.blank('/v1/a/c/obj.txt.gz',
                         environ={
                             'REQUEST_METHOD': 'PUT',
                             'swift.cache': self.cache
                         })
     res = req.get_response(app)
     self.assertEqual(res.environ.get('HTTP_CONTENT_TYPE'), 'text/plain')
     self.assertEqual(res.environ.get('HTTP_CONTENT_ENCODING'), 'gzip')
     self.assertEqual(res.status_int, 200)
示例#4
0
    def test_meta_not_set(self):
        app = middleware.AutoMimeMiddleware(FakeApp(), {})
        req = Request.blank('/v1/a/c/obj.txt',
                            environ={
                                'REQUEST_METHOD': 'PUT',
                                'swift.cache': FakeCache({'meta': {}})
                            })

        res = req.get_response(app)
        self.assertEqual(res.environ.get('HTTP_CONTENT_TYPE'), None)
        self.assertFalse(res.environ.get('HTTP_CONTENT_ENCODING', None))
        self.assertEqual(res.status_int, 200)