Skip to content

Commit

Permalink
s3tests: modify test_get_object_ifmodifiedsince_failed
Browse files Browse the repository at this point in the history
Use key's last_modified instead of local time

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed May 17, 2016
1 parent 3e3eb49 commit 99f237e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions s3tests/functional/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 99f237e

Please sign in to comment.