Skip to content

Commit a755b3e

Browse files
committed
refactor: improve assertions in test_handler_success
1 parent 660d113 commit a755b3e

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

tests/test_main.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ class TestHandler:
6060
@patch("src.main.github_api_toolkit.get_token_as_installation")
6161
@patch("src.main.github_api_toolkit.github_interface")
6262
@patch("src.main.get_and_update_historic_usage")
63-
@patch("src.main.update_s3_object")
6463
def test_handler_success(
6564
self,
66-
mock_update_s3_object,
6765
mock_get_and_update_historic_usage,
6866
mock_github_interface,
6967
mock_get_token_as_installation,
@@ -87,22 +85,15 @@ def test_handler_success(
8785
secret_region = "eu-west-1"
8886
secret_name = "test-secret"
8987

90-
# S3 get_object for teams_history.json returns existing history
91-
mock_s3.get_object.return_value = {
92-
"Body": MagicMock(
93-
read=MagicMock(return_value=b'[{"team": {"name": "team1"}, "data": []}]')
94-
)
95-
}
96-
9788
result = handler({}, MagicMock())
9889
assert result == "Github Data logging is now complete."
9990
mock_boto3_session.assert_called_once()
10091
mock_session.client.assert_any_call("s3")
10192
call("secretsmanager", region_name=secret_region) in mock_session.client.call_args_list
10293
mock_secret_manager.get_secret_value.assert_called_once_with(SecretId=secret_name)
10394
mock_get_token_as_installation.assert_called_once()
104-
mock_github_interface.assert_called_once()
105-
mock_get_and_update_historic_usage.assert_called_once()
95+
mock_github_interface.assert_called_once_with("token")
96+
mock_get_and_update_historic_usage.assert_called_once_with(mock_s3, mock_gh, False)
10697

10798
@patch("src.main.boto3.Session")
10899
@patch("src.main.github_api_toolkit.get_token_as_installation")

0 commit comments

Comments
 (0)