File: test_s3_response_headers.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (32 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import boto3
import pytest

from . import s3_aws_verified
from .test_s3 import DEFAULT_REGION_NAME


@pytest.mark.aws_verified
@s3_aws_verified
def test_header_content_type(bucket_name=None):
    client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)

    resp = client.list_buckets()
    headers = resp["ResponseMetadata"]["HTTPHeaders"]
    assert headers.get("content-type") == "application/xml"

    resp = client.list_object_versions(Bucket=bucket_name)
    headers = resp["ResponseMetadata"]["HTTPHeaders"]
    assert headers.get("content-type") == "application/xml"

    resp = client.head_bucket(Bucket=bucket_name)
    headers = resp["ResponseMetadata"]["HTTPHeaders"]
    assert headers.get("content-type") == "application/xml"

    resp = client.put_object(Bucket=bucket_name, Key="key", Body=b"data")
    headers = resp["ResponseMetadata"]["HTTPHeaders"]
    # Werkzeug automatically adds a content-type if none is specified
    assert headers.get("content-type") in [None, "text/html; charset=utf-8"]

    resp = client.get_object(Bucket=bucket_name, Key="key")
    headers = resp["ResponseMetadata"]["HTTPHeaders"]
    assert headers.get("content-type") == "binary/octet-stream"