Skip to content

Commit

Permalink
clean up docs code and remove superfluous test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlm committed Sep 18, 2023
1 parent 09b0cf1 commit 9929e41
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 73 deletions.
4 changes: 2 additions & 2 deletions botocore/docs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class ClientContextParamsDocumenter:
# These context params provide overlapping functionality to settings in
# the ``s3`` config. While they will still be supported, they are
# undocumented to prevent customers from implementing conflicting behavior
# in the SDK.
# in the SDK.
_OMITTED_S3_PARAMS = ['Accelerate', 'ForcePathStyle']

def __init__(self, context_params, service_name):
Expand All @@ -435,7 +435,7 @@ def _add_overview(self, section):
section.style.new_line()
section.write(
'Client context parameters are configurable on a client '
'instance via the ``client_context_params`` parameter on the '
'instance via the ``client_context_params`` parameter in the '
'``Config`` object. For more detailed instructions and examples '
'on the exact usage of context params see the '
)
Expand Down
5 changes: 3 additions & 2 deletions botocore/docs/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def client_context_params(self, section):
service_model = self._client.meta.service_model
context_params = service_model.client_context_parameters
if context_params:
ClientContextParamsDocumenter(
context_param_documenter = ClientContextParamsDocumenter(
context_params, self._service_name
).document_context_params(section)
)
context_param_documenter.document_context_params(section)
2 changes: 2 additions & 0 deletions botocore/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ def _resolve_param_as_client_context_param(self, param_name):
)

def _resolve_client_context_param_value(self, param_value, ctx_param):
# boolean and string are the only officially supported types for
# client context params
if ctx_param.type == 'boolean':
return ensure_boolean(param_value)

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def get_client_context_params_block(self, contents):
self.assertNotEqual(
start_index, -1, 'Context param section is not found in contents'
)
# context params are at the end of the service client file
# Context params are at the end of the service client file. This may
# change in the future. If it does, an end index should be calculated.
contents = contents[start_index:]
return contents.encode('utf-8')

Expand Down
75 changes: 7 additions & 68 deletions tests/functional/test_context_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
"metadata": S3CONTROL_METADATA,
}
CLIENT_CONTEXT_PARAM_INPUT = {
'foo_client_context_param_name': 'foo_context_param_value'
"foo_client_context_param_name": "foo_context_param_value"
}
CONFIG_WITH_S3 = Config(s3=CLIENT_CONTEXT_PARAM_INPUT)
CONFIG_WITH_CLIENT_CONTEXT_PARAMS = Config(
Expand Down Expand Up @@ -299,27 +299,6 @@
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3',
FAKE_S3_MODEL_WITH_CLIENT_CONTEXT_PARAM,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3',
FAKE_S3_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITH_CLIENT_CONTEXT_PARAM,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3',
FAKE_S3_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
# s3control
(
's3control',
Expand Down Expand Up @@ -356,27 +335,6 @@
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3control',
FAKE_S3CONTROL_MODEL_WITH_CLIENT_CONTEXT_PARAM,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3control',
FAKE_S3CONTROL_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITH_CLIENT_CONTEXT_PARAM,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
's3control',
FAKE_S3CONTROL_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_S3,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
# otherservice
(
'otherservice',
Expand Down Expand Up @@ -410,36 +368,17 @@
'otherservice',
FAKE_MODEL_WITH_CLIENT_CONTEXT_PARAM,
FAKE_RULESET_WITH_CLIENT_CONTEXT_PARAM,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
'otherservice',
FAKE_MODEL_WITH_CLIENT_CONTEXT_PARAM,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
'otherservice',
FAKE_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITH_CLIENT_CONTEXT_PARAM,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
),
(
'otherservice',
FAKE_MODEL_WITHOUT_ANY_CONTEXT_PARAMS,
FAKE_RULESET_WITHOUT_ANY_CONTEXT_PARAMS,
CONFIG_WITH_CLIENT_CONTEXT_PARAMS,
NO_CTX_PARAM_EXPECTED_CALL_KWARGS,
Config(client_context_params={"foo_client_context_param_name": 5}),
{"Region": "us-east-1", "FooClientContextParamName": "5"},
),
(
'otherservice',
FAKE_MODEL_WITH_CLIENT_CONTEXT_PARAM,
FAKE_RULESET_WITH_CLIENT_CONTEXT_PARAM,
Config(client_context_params={"foo_client_context_param_name": 5}),
{"Region": "us-east-1", "FooClientContextParamName": "5"},
Config(
client_context_params={"foo_client_context_param_name": "foo"}
),
{"Region": "us-east-1", "FooClientContextParamName": "foo"},
),
(
'otherservice',
Expand Down

0 comments on commit 9929e41

Please sign in to comment.