File: test_url_base_regex.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 (33 lines) | stat: -rw-r--r-- 1,093 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
33
import boto3
import pytest

from moto import mock_aws
from moto.backends import list_of_moto_modules


class TestMockBucketStartingWithServiceName:
    """
    https://github.com/getmoto/moto/issues/4099
    """

    @pytest.mark.parametrize("service_name", list(list_of_moto_modules()))
    def test_bucketname_starting_with_service_name(self, service_name: str) -> None:
        with mock_aws():
            s3_client = boto3.client("s3", "eu-west-1")
            bucket_name = f"{service_name}-bucket"
            s3_client.create_bucket(
                ACL="private",
                Bucket=bucket_name,
                CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
            )


@mock_aws
def test_dynamodb_account_based_endpoint() -> None:
    dynamodb_account_based_endpoint_service_name = "ddb"
    s3_client = boto3.client("s3", "us-east-1")
    bucket_name = (
        f"bucket-name-ends-with-{dynamodb_account_based_endpoint_service_name}"
    )
    resp = s3_client.create_bucket(Bucket=bucket_name)
    assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200