Skip to content

Commit 5d53504

Browse files
style: Apply Black formatting to test files
- Applied Black formatter to all test files - Fixed line spacing and string formatting issues - No functional changes, only code style updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 66dc0e8 commit 5d53504

File tree

6 files changed

+40
-84
lines changed

6 files changed

+40
-84
lines changed

tests/test_aws_client.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def test_list_claude_models_success(self, mock_run, mock_aws_response):
2828
"""Test successful listing of Claude models."""
2929
# Arrange
3030
client = BedrockClient("us-west-2")
31-
mock_run.return_value = MagicMock(
32-
returncode=0, stdout=json.dumps(mock_aws_response)
33-
)
31+
mock_run.return_value = MagicMock(returncode=0, stdout=json.dumps(mock_aws_response))
3432

3533
# Act
3634
result = client.list_claude_models()
@@ -100,9 +98,7 @@ def test_list_claude_models_no_claude_models(self, mock_run):
10098
}
10199
]
102100
}
103-
mock_run.return_value = MagicMock(
104-
returncode=0, stdout=json.dumps(non_claude_response)
105-
)
101+
mock_run.return_value = MagicMock(returncode=0, stdout=json.dumps(non_claude_response))
106102

107103
# Act
108104
result = client.list_claude_models()
@@ -129,9 +125,7 @@ def test_list_claude_models_missing_profile_name(self, mock_run):
129125
}
130126
]
131127
}
132-
mock_run.return_value = MagicMock(
133-
returncode=0, stdout=json.dumps(response_without_name)
134-
)
128+
mock_run.return_value = MagicMock(returncode=0, stdout=json.dumps(response_without_name))
135129

136130
# Act
137131
result = client.list_claude_models()
@@ -155,10 +149,7 @@ def test_list_claude_models_access_denied_error(self, mock_run):
155149
# Act & Assert
156150
with pytest.raises(
157151
Exception,
158-
match=(
159-
"Access denied. Please check your AWS "
160-
"permissions for Amazon Bedrock."
161-
),
152+
match=("Access denied. Please check your AWS " "permissions for Amazon Bedrock."),
162153
):
163154
client.list_claude_models()
164155

@@ -172,10 +163,7 @@ def test_list_claude_models_not_authorized_error(self, mock_run):
172163
error = subprocess.CalledProcessError(
173164
1,
174165
"aws",
175-
stderr=(
176-
"The security token included in the request is invalid. "
177-
"not authorized"
178-
),
166+
stderr=("The security token included in the request is invalid. " "not authorized"),
179167
)
180168
mock_run.side_effect = error
181169

@@ -227,9 +215,7 @@ def test_list_claude_models_unexpected_error(self, mock_run):
227215
mock_run.side_effect = RuntimeError("Unexpected runtime error")
228216

229217
# Act & Assert
230-
with pytest.raises(
231-
Exception, match="Unexpected error: Unexpected runtime error"
232-
):
218+
with pytest.raises(Exception, match="Unexpected error: Unexpected runtime error"):
233219
client.list_claude_models()
234220

235221
mock_run.assert_called_once()
@@ -240,9 +226,7 @@ def test_list_claude_models_custom_region(self, mock_run, mock_aws_response):
240226
# Arrange
241227
custom_region = "eu-west-1"
242228
client = BedrockClient(custom_region)
243-
mock_run.return_value = MagicMock(
244-
returncode=0, stdout=json.dumps(mock_aws_response)
245-
)
229+
mock_run.return_value = MagicMock(returncode=0, stdout=json.dumps(mock_aws_response))
246230

247231
# Act
248232
result = client.list_claude_models()
@@ -275,9 +259,7 @@ def test_list_claude_models_partial_data(self, mock_run):
275259
}
276260
]
277261
}
278-
mock_run.return_value = MagicMock(
279-
returncode=0, stdout=json.dumps(partial_response)
280-
)
262+
mock_run.return_value = MagicMock(returncode=0, stdout=json.dumps(partial_response))
281263

282264
# Act
283265
result = client.list_claude_models()

tests/test_cli.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ def test_setup_custom_region(
168168
mock_config_class.return_value = mock_config
169169

170170
# Act
171-
result = self.runner.invoke(
172-
setup, ["--region", "eu-west-1", "--non-interactive"]
173-
)
171+
result = self.runner.invoke(setup, ["--region", "eu-west-1", "--non-interactive"])
174172

175173
# Assert
176174
assert result.exit_code == 0
@@ -334,9 +332,7 @@ def test_status_with_configuration(self, mock_config_class, mock_settings):
334332
assert "Current settings:" in result.output
335333
assert "CLAUDE_CODE_USE_BEDROCK: 1" in result.output
336334
assert "AWS_REGION: us-west-2" in result.output
337-
assert (
338-
"anthropic.claude-3-sonnet-20240229-v1:0" in result.output
339-
) # Extracted from ARN
335+
assert "anthropic.claude-3-sonnet-20240229-v1:0" in result.output # Extracted from ARN
340336
assert "Settings file: /test/.claude/settings.local.json" in result.output
341337
mock_config.load_settings.assert_called_once()
342338

@@ -360,9 +356,7 @@ def test_status_arn_extraction(self, mock_config_class):
360356

361357
# Assert
362358
assert result.exit_code == 0
363-
assert (
364-
"ANTHROPIC_MODEL: anthropic.claude-3-haiku-20240307-v1:0" in result.output
365-
)
359+
assert "ANTHROPIC_MODEL: anthropic.claude-3-haiku-20240307-v1:0" in result.output
366360

367361
@patch.object(sys.modules["claude_setup.cli"], "ConfigManager")
368362
def test_status_simple_model_id(self, mock_config_class):

tests/test_config_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_save_settings_new_file(self, mock_file, mock_mkdir):
5252
# write was called
5353
assert mock_file().write.called
5454

55-
5655
@patch("builtins.open", new_callable=mock_open, read_data='{"key": "value"}')
5756
@patch("claude_setup.config_manager.Path.exists")
5857
def test_load_settings_legacy_format(self, mock_exists, mock_file):
@@ -68,7 +67,7 @@ def test_load_settings_legacy_format(self, mock_exists, mock_file):
6867
assert result == {"key": "value"}
6968
mock_exists.assert_called_once()
7069
mock_file.assert_called_once_with(config_manager.settings_path, "r")
71-
70+
7271
@patch("builtins.open", new_callable=mock_open, read_data='{"env": {"key": "value"}}')
7372
@patch("claude_setup.config_manager.Path.exists")
7473
def test_load_settings_new_format(self, mock_exists, mock_file):
@@ -213,7 +212,7 @@ def test_load_settings_empty_file(self, mock_exists, mock_file):
213212
assert result == {}
214213
mock_exists.assert_called_once()
215214
mock_file.assert_called_once_with(config_manager.settings_path, "r")
216-
215+
217216
@patch("builtins.open", new_callable=mock_open, read_data='{"env": {}}')
218217
@patch("claude_setup.config_manager.Path.exists")
219218
def test_load_settings_empty_env(self, mock_exists, mock_file):

tests/test_gitignore_manager.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def test_ensure_gitignore_empty_file(self, mock_exists, mock_file):
2929
mock_file.assert_any_call(Path(".gitignore"), "w")
3030

3131
# Check the written content
32-
write_call = [
33-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
34-
][-1]
32+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
33+
-1
34+
]
3535
written_content = write_call[0][0]
3636
assert ".claude/settings.local.json\n" == written_content
3737

@@ -56,9 +56,9 @@ def test_ensure_gitignore_existing_content(self, mock_exists, mock_file):
5656
mock_file.assert_any_call(Path(".gitignore"), "w")
5757

5858
# Check the written content includes existing and new patterns
59-
write_call = [
60-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
61-
][-1]
59+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
60+
-1
61+
]
6262
written_content = write_call[0][0]
6363
assert "node_modules/\n*.log\n.claude/settings.local.json\n" == written_content
6464

@@ -118,9 +118,9 @@ def test_ensure_gitignore_whitespace_only_file(self, mock_exists, mock_file):
118118
mock_file.assert_any_call(Path(".gitignore"), "w")
119119

120120
# Check the written content
121-
write_call = [
122-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
123-
][-1]
121+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
122+
-1
123+
]
124124
written_content = write_call[0][0]
125125
assert ".claude/settings.local.json\n" == written_content
126126

@@ -130,9 +130,7 @@ def test_ensure_gitignore_whitespace_only_file(self, mock_exists, mock_file):
130130
read_data="node_modules/\n# Comment\n\n*.log\n",
131131
)
132132
@patch("claude_setup.gitignore_manager.Path.exists")
133-
def test_ensure_gitignore_with_comments_and_empty_lines(
134-
self, mock_exists, mock_file
135-
):
133+
def test_ensure_gitignore_with_comments_and_empty_lines(self, mock_exists, mock_file):
136134
"""Test handling .gitignore with comments and empty lines."""
137135
# Arrange
138136
mock_exists.return_value = True
@@ -145,9 +143,9 @@ def test_ensure_gitignore_with_comments_and_empty_lines(
145143
assert mock_file.call_count == 2
146144

147145
# Check the written content preserves structure
148-
write_call = [
149-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
150-
][-1]
146+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
147+
-1
148+
]
151149
written_content = write_call[0][0]
152150
expected = "node_modules/\n# Comment\n\n*.log\n.claude/settings.local.json\n"
153151
assert expected == written_content
@@ -209,9 +207,7 @@ def test_ensure_gitignore_similar_pattern_exists(self, mock_exists, mock_file):
209207
read_data="node_modules/\n.claude/settings.local.json \n*.log\n",
210208
)
211209
@patch("claude_setup.gitignore_manager.Path.exists")
212-
def test_ensure_gitignore_pattern_with_trailing_spaces(
213-
self, mock_exists, mock_file
214-
):
210+
def test_ensure_gitignore_pattern_with_trailing_spaces(self, mock_exists, mock_file):
215211
"""Test that trailing spaces in existing pattern don't match."""
216212
# Arrange
217213
mock_exists.return_value = True
@@ -227,9 +223,9 @@ def test_ensure_gitignore_pattern_with_trailing_spaces(
227223

228224
# Check that the pattern was added despite similar line
229225
# with trailing spaces
230-
write_call = [
231-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
232-
][-1]
226+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
227+
-1
228+
]
233229
written_content = write_call[0][0]
234230
assert ".claude/settings.local.json" in written_content
235231
# Should have both the original line with spaces and the new clean line
@@ -270,8 +266,8 @@ def test_ensure_gitignore_no_trailing_newline(self, mock_exists, mock_file):
270266
assert mock_file.call_count == 2
271267

272268
# Check the written content adds pattern properly
273-
write_call = [
274-
call for call in mock_file.return_value.write.call_args_list if call[0][0]
275-
][-1]
269+
write_call = [call for call in mock_file.return_value.write.call_args_list if call[0][0]][
270+
-1
271+
]
276272
written_content = write_call[0][0]
277273
assert "line1\nline2\nline3\n.claude/settings.local.json\n" == written_content

tests/test_integration.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def test_complete_setup_workflow(
3636
"""Test complete setup workflow from start to finish."""
3737
# Arrange
3838
mock_auth.return_value = True
39-
mock_subprocess.return_value = MagicMock(
40-
returncode=0, stdout=json.dumps(mock_aws_response)
41-
)
39+
mock_subprocess.return_value = MagicMock(returncode=0, stdout=json.dumps(mock_aws_response))
4240

4341
with self.runner.isolated_filesystem():
4442
# Act - Run setup
@@ -78,30 +76,22 @@ def test_complete_setup_workflow(
7876

7977
@patch.object(sys.modules["claude_setup.auth_checker"], "check_aws_auth")
8078
@patch("claude_setup.aws_client.subprocess.run")
81-
def test_setup_with_different_regions(
82-
self, mock_subprocess, mock_auth, mock_aws_response
83-
):
79+
def test_setup_with_different_regions(self, mock_subprocess, mock_auth, mock_aws_response):
8480
"""Test setup workflow with different AWS regions."""
8581
# Arrange
8682
mock_auth.return_value = True
87-
mock_subprocess.return_value = MagicMock(
88-
returncode=0, stdout=json.dumps(mock_aws_response)
89-
)
83+
mock_subprocess.return_value = MagicMock(returncode=0, stdout=json.dumps(mock_aws_response))
9084

9185
regions = ["us-east-1", "eu-west-1", "ap-southeast-1"]
9286

9387
for region in regions:
9488
with self.runner.isolated_filesystem():
9589
# Act
96-
result = self.runner.invoke(
97-
cli, ["setup", "--region", region, "--non-interactive"]
98-
)
90+
result = self.runner.invoke(cli, ["setup", "--region", region, "--non-interactive"])
9991

10092
# Assert
10193
assert result.exit_code == 0
102-
assert (
103-
f"Fetching available Claude models from {region}" in result.output
104-
)
94+
assert f"Fetching available Claude models from {region}" in result.output
10595

10696
# Verify region in configuration
10797
config_manager = ConfigManager()
@@ -275,10 +265,7 @@ def test_bedrock_api_error_workflow(self, mock_auth, mock_subprocess):
275265
# Assert - The exception from BedrockClient causes the CLI to exit
276266
assert result.exit_code != 0
277267
# The exception message should appear in the result
278-
assert (
279-
"Access denied" in str(result.exception)
280-
or "Access denied" in result.output
281-
)
268+
assert "Access denied" in str(result.exception) or "Access denied" in result.output
282269

283270
# Verify no configuration was created
284271
config_manager = ConfigManager()

tests/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ class CLITestHelper:
150150
"""Helper class for CLI testing."""
151151

152152
@staticmethod
153-
def run_cli_command(
154-
runner, command, args=None, input_data=None, catch_exceptions=True
155-
):
153+
def run_cli_command(runner, command, args=None, input_data=None, catch_exceptions=True):
156154
"""Run a CLI command with standard error handling.
157155
158156
Args:

0 commit comments

Comments
 (0)