forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR feedback and add some unit tests for utils
Signed-off-by: Tanner Lewis <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...ture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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_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) | ||
assert result_headers == expected_headers | ||
|
||
def test_append_user_agent_header_for_requests_existing_headers(): | ||
existing_headers = {"Accept": "/*", "Host": "macosx"} | ||
expected_headers = dict(existing_headers) | ||
expected_headers["User-Agent"] = f"{requests.utils.default_user_agent()} {USER_AGENT_EXTRA}" | ||
result_headers = append_user_agent_header_for_requests(headers=existing_headers, user_agent_extra=USER_AGENT_EXTRA) | ||
assert result_headers == expected_headers | ||
|
||
def test_append_user_agent_header_for_requests_existing_headers_with_user_agent(): | ||
existing_headers = {"Accept": "/*", "Host": "macosx", "User-Agent": "pyclient"} | ||
expected_headers = dict(existing_headers) | ||
expected_headers["User-Agent"] = f"pyclient {USER_AGENT_EXTRA}" | ||
result_headers = append_user_agent_header_for_requests(headers=existing_headers, user_agent_extra=USER_AGENT_EXTRA) | ||
assert result_headers == expected_headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters