From 99f237e552f96d1b712b6ffc7ec36d79f4b40a06 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 17 May 2016 14:33:40 -0700 Subject: [PATCH] s3tests: modify test_get_object_ifmodifiedsince_failed Use key's last_modified instead of local time Signed-off-by: Yehuda Sadeh --- s3tests/functional/test_s3.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 58a738e..4cda267 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -2357,11 +2357,14 @@ def test_get_object_ifmodifiedsince_failed(): key = bucket.new_key('foo') key.set_contents_from_string('bar') - # Sleep since Amazon returns 200 if the date is in the future: - # https://forums.aws.amazon.com/message.jspa?messageID=325930 - now = time.time() - time.sleep(20) - after = formatdate(now + 10) + for k in bucket.get_all_keys(): + key = k + + mtime = time.strptime(key.last_modified, '%Y-%m-%dT%H:%M:%S.%fZ') + + after = time.ctime(time.mktime(mtime) + 1) + + time.sleep(1) e = assert_raises(boto.exception.S3ResponseError, bucket.get_key, 'foo', headers={'If-Modified-Since': after}) eq(e.status, 304)