Add tests for metadata on 304 and 412 responses

Commit 1f67eb74 added support for If-[None-]Match on DLOs and SLOs. It
also made the 304 and 412 responses have the Content-Type and
X-Object-Meta-* headers from the object instead of just having the
Etag.

Someone showed up in IRC today looking for this behavior, and was
happy to learn it's in newer Swift versions than the one they were
running. If we've got clients depending on this, we should have some
unit tests to make sure we don't accidentally take it out again.

Change-Id: If06149d13140148463004d426cb7ba4c5601404a
This commit is contained in:
Samuel Merritt 2014-12-12 11:56:42 -08:00
parent cc2f0f4ed6
commit f48350865e

View File

@ -1335,7 +1335,8 @@ class TestObjectController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={
'X-Timestamp': normalize_timestamp(time()),
'Content-Type': 'application/octet-stream',
'X-Object-Meta-Soup': 'gazpacho',
'Content-Type': 'application/fizzbuzz',
'Content-Length': '4'})
req.body = 'test'
resp = req.get_response(self.object_controller)
@ -1352,6 +1353,8 @@ class TestObjectController(unittest.TestCase):
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 304)
self.assertEquals(resp.etag, etag)
self.assertEquals(resp.headers['Content-Type'], 'application/fizzbuzz')
self.assertEquals(resp.headers['X-Object-Meta-Soup'], 'gazpacho')
req = Request.blank('/sda1/p/a/c/o2',
environ={'REQUEST_METHOD': 'GET'},
@ -1579,7 +1582,8 @@ class TestObjectController(unittest.TestCase):
req = Request.blank('/sda1/p/a/c/o', environ={'REQUEST_METHOD': 'PUT'},
headers={
'X-Timestamp': timestamp,
'Content-Type': 'application/octet-stream',
'X-Object-Meta-Burr': 'ito',
'Content-Type': 'application/cat-picture',
'Content-Length': '4'})
req.body = 'test'
resp = req.get_response(self.object_controller)
@ -1602,6 +1606,9 @@ class TestObjectController(unittest.TestCase):
headers={'If-Unmodified-Since': since})
resp = req.get_response(self.object_controller)
self.assertEquals(resp.status_int, 412)
self.assertEquals(resp.headers['Content-Type'],
'application/cat-picture')
self.assertEquals(resp.headers['X-Object-Meta-Burr'], 'ito')
since = \
strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(float(timestamp) + 9))