Example #1
0
def H(ctype, *hpairs):
    n = datetime.datetime.now()
    msg = MockHTTPMessage([("x-amz-request-id", "abcdef"),
                           ("x-amz-id-2", "foobar"), ("Server", "AmazonS3"),
                           ("Date", rfc822_fmtdate(n))])
    msg["Content-Type"] = ctype
    for h, v in hpairs:
        msg[h] = v
    return msg
Example #2
0
 def test_get(self):
     dt = datetime.datetime(1990, 1, 31, 12, 34, 56)
     headers = g.H("text/plain", ("date", rfc822_fmtdate(dt)),
                   ("x-amz-meta-foo", "bar"))
     g.bucket.add_resp("/foo.txt", headers, "ohi")
     fp = g.bucket["foo.txt"]
     eq_(fp.s3_info["mimetype"], "text/plain")
     eq_(fp.s3_info["metadata"], {"foo": "bar"})
     eq_(fp.s3_info["date"], dt)
     eq_(fp.read().decode("ascii"), "ohi")
Example #3
0
 def test_get(self):
     dt = datetime.datetime(1990, 1, 31, 12, 34, 56)
     headers = g.H("text/plain",
         ("date", rfc822_fmtdate(dt)),
         ("x-amz-meta-foo", "bar"))
     g.bucket.add_resp("/foo.txt", headers, "ohi")
     fp = g.bucket["foo.txt"]
     eq_(fp.s3_info["mimetype"], "text/plain")
     eq_(fp.s3_info["metadata"], {"foo": "bar"})
     eq_(fp.s3_info["date"], dt)
     eq_(fp.read().decode("ascii"), "ohi")
Example #4
0
def H(ctype, *hpairs):
    n = datetime.datetime.now()
    msg = MockHTTPMessage([
        ("x-amz-request-id", "abcdef"),
        ("x-amz-id-2", "foobar"),
        ("Server", "AmazonS3"),
        ("Date", rfc822_fmtdate(n))])
    msg["Content-Type"] = ctype
    for h, v in hpairs:
        msg[h] = v
    return msg
Example #5
0
 def __init__(self,
              bucket=None,
              key=None,
              method="GET",
              headers={},
              args=None,
              data=None,
              subresource=None):
     headers = headers.copy()
     if data and "Content-MD5" not in headers:
         headers["Content-MD5"] = aws_md5(data)
     if "Date" not in headers:
         headers["Date"] = rfc822_fmtdate()
     if hasattr(bucket, "name"):
         bucket = bucket.name
     self.bucket = bucket
     self.key = key
     self.method = method
     self.headers = headers
     self.args = args
     self.data = data
     self.subresource = subresource
Example #6
0
def test_rfc822():
    s = rfc822_fmtdate()
    dt = rfc822_parsedate(s)
    eq_(s, rfc822_fmtdate(dt))
    eq_(dt, rfc822_parsedate(s))
Example #7
0
def test_rfc822():
    s = rfc822_fmtdate()
    dt = rfc822_parsedate(s)
    eq_(s, rfc822_fmtdate(dt))
    eq_(dt, rfc822_parsedate(s))