From 346ef9c3ae45e192489ea50aae07d3e61bf16f44 Mon Sep 17 00:00:00 2001 From: Tanner Lewis Date: Fri, 20 Sep 2024 15:45:27 -0500 Subject: [PATCH] Add tests for create boto3 client Signed-off-by: Tanner Lewis --- .../lib/console_link/tests/test_utils.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py index 0771b9f5c..c833d563b 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py @@ -1,9 +1,23 @@ -from console_link.models.utils import append_user_agent_header_for_requests +from console_link.models.client_options import ClientOptions +from console_link.models.utils import append_user_agent_header_for_requests,create_boto3_client import requests.utils + USER_AGENT_EXTRA = "test-user-agent-v1.0" +def test_create_boto3_client_no_user_agent(): + client = create_boto3_client(aws_service_name="ecs") + user_agent_for_client = client.meta.config.user_agent + assert "Boto3" in user_agent_for_client + +def test_create_boto3_client_with_user_agent(): + client_options = ClientOptions(config={"user_agent_extra": USER_AGENT_EXTRA}) + client = create_boto3_client(aws_service_name="ecs", client_options=client_options) + user_agent_for_client = client.meta.config.user_agent + assert "Boto3" in user_agent_for_client + assert USER_AGENT_EXTRA in user_agent_for_client + def test_append_user_agent_header_for_requests_no_headers(): expected_headers = {"User-Agent": f"{requests.utils.default_user_agent()} {USER_AGENT_EXTRA}"} result_headers = append_user_agent_header_for_requests(headers=None, user_agent_extra=USER_AGENT_EXTRA)