Skip to content

Commit 0cccacf

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Fixed TestObjectController.test_PUT_auto_content_type()"
2 parents 9e77f46 + 50b437a commit 0cccacf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/unit/proxy/test_server.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def getheader(self, name, default=None):
228228

229229
def connect(*args, **ckwargs):
230230
if 'give_content_type' in kwargs:
231-
if len(args) >= 7 and 'content_type' in args[6]:
232-
kwargs['give_content_type'](args[6]['content-type'])
231+
if len(args) >= 7 and 'Content-Type' in args[6]:
232+
kwargs['give_content_type'](args[6]['Content-Type'])
233233
else:
234234
kwargs['give_content_type']('')
235235
if 'give_connect' in kwargs:
@@ -795,17 +795,26 @@ def test_PUT_auto_content_type(self):
795795
'container', 'object')
796796

797797
def test_content_type(filename, expected):
798-
proxy_server.http_connect = fake_http_connect(201, 201, 201,
798+
# The three responses here are for account_info() (HEAD to account server),
799+
# container_info() (HEAD to container server) and three calls to
800+
# _connect_put_node() (PUT to three object servers)
801+
proxy_server.http_connect = fake_http_connect(201, 201, 201, 201, 201,
799802
give_content_type=lambda content_type:
800803
self.assertEquals(content_type, expected.next()))
801-
req = Request.blank('/a/c/%s' % filename, {})
804+
# We need into include a transfer-encoding to get past
805+
# constraints.check_object_creation()
806+
req = Request.blank('/a/c/%s' % filename, {}, headers={'transfer-encoding': 'chunked'})
802807
self.app.update_request(req)
808+
self.app.memcache.store = {}
803809
res = controller.PUT(req)
804-
test_content_type('test.jpg', iter(['', '', '', 'image/jpeg',
810+
# If we don't check the response here we could miss problems in PUT()
811+
self.assertEquals(res.status_int, 201)
812+
813+
test_content_type('test.jpg', iter(['', '', 'image/jpeg',
805814
'image/jpeg', 'image/jpeg']))
806-
test_content_type('test.html', iter(['', '', '', 'text/html',
815+
test_content_type('test.html', iter(['', '', 'text/html',
807816
'text/html', 'text/html']))
808-
test_content_type('test.css', iter(['', '', '', 'text/css',
817+
test_content_type('test.css', iter(['', '', 'text/css',
809818
'text/css', 'text/css']))
810819

811820
def test_custom_mime_types_files(self):

0 commit comments

Comments
 (0)