Skip to content

Commit

Permalink
test coverage for s3transfer and chalice user agent behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jonemo committed Jun 28, 2023
1 parent 03db799 commit 016e449
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/functional/test_useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,31 @@ def test_awscli_v2_user_agent(patched_session):
assert ' os/' in stub_client.captured_ua_string
assert ' lang/' in stub_client.captured_ua_string
assert ' cfg/' in stub_client.captured_ua_string


def test_s3transfer_user_agent(patched_session):
# emulate behavior from s3transfer ClientFactory
cfg = Config(user_agent_extra='s3transfer/0.1.2 processpool')
client = patched_session.create_client('s3', config=cfg)
# s3transfer tests make assertions against the _modified_ `user_agent` field
# in ``client.meta.config.user_agent``. See for example
# ``tests.unit.test_processpool.TestClientFactory`` in s3transfer.
assert 'processpool' in client.meta.config.user_agent


def test_chalice_user_agent(patched_session):
# emulate behavior from chalice's cli.factory._add_chalice_user_agent
suffix = '%s/%s' % (
patched_session.user_agent_name,
patched_session.user_agent_version,
)
patched_session.user_agent_name = 'aws-chalice'
patched_session.user_agent_version = '0.1.2'
patched_session.user_agent_extra = suffix
client_s3 = patched_session.create_client('s3')

with UACapHTTPStubber(client_s3) as stub_client:
client_s3.list_buckets()
assert stub_client.captured_ua_string.startswith(
f'aws-chalice/0.1.2 md/Botocore#{botocore_version} '
)

0 comments on commit 016e449

Please sign in to comment.