File: test_config_provider.py

package info (click to toggle)
python-botocore 1.29.27%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 99,520 kB
  • sloc: python: 65,796; xml: 15,052; makefile: 131
file content (51 lines) | stat: -rw-r--r-- 1,998 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import pytest

from botocore.config import Config
from botocore.session import get_session

_SDK_DEFAULT_CONFIGURATION_VALUES_ALLOWLIST = (
    'retryMode',
    'stsRegionalEndpoints',
    's3UsEast1RegionalEndpoints',
    'connectTimeoutInMillis',
    'tlsNegotiationTimeoutInMillis',
)

session = get_session()
loader = session.get_component('data_loader')
sdk_default_configuration = loader.load_data('sdk-default-configuration')


@pytest.mark.parametrize("mode", sdk_default_configuration['base'])
def test_no_new_sdk_default_configuration_values(mode):
    err_msg = (
        f'New default configuration value {mode} introduced to '
        f'sdk-default-configuration.json. Support for setting {mode} must be '
        'considered and added to the DefaulConfigResolver. In addition, '
        'must add value to _SDK_DEFAULT_CONFIGURATION_VALUES_ALLOWLIST.'
    )
    assert mode in _SDK_DEFAULT_CONFIGURATION_VALUES_ALLOWLIST, err_msg


def test_default_configurations_resolve_correctly():
    session = get_session()
    config = Config(defaults_mode='standard')
    client = session.create_client(
        'sts', config=config, region_name='us-west-2'
    )
    assert client.meta.config.s3['us_east_1_regional_endpoint'] == 'regional'
    assert client.meta.config.connect_timeout == 3.1
    assert client.meta.endpoint_url == 'https://sts.us-west-2.amazonaws.com'
    assert client.meta.config.retries['mode'] == 'standard'