Skip to content

Commit

Permalink
fix(job_attachments): improvements to nonvalid error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Gahyun Suh <132245153+gahyusuh@users.noreply.github.com>
  • Loading branch information
gahyusuh committed Mar 7, 2024
1 parent 66126a1 commit 148587a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/deadline/job_attachments/_aws/aws_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_s3_max_pool_connections() -> int:
) from ve
if s3_max_pool_connections <= 0:
raise AssetSyncError(
f"s3_max_pool_connections ({s3_max_pool_connections}) must be positive integer."
f"Nonvalid value for configuration setting: 's3_max_pool_connections' ({s3_max_pool_connections}) must be positive integer."
)
return s3_max_pool_connections

Expand Down
6 changes: 3 additions & 3 deletions src/deadline/job_attachments/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ def __init__(
# Confirm that the settings values are all positive.
error_msg = ""
if small_file_threshold_multiplier <= 0:
error_msg = f"small_file_threshold_multiplier ({small_file_threshold_multiplier}) must be positive integer."
error_msg = f"'small_file_threshold_multiplier' ({small_file_threshold_multiplier}) must be positive integer."
elif s3_max_pool_connections <= 0:
error_msg = (
f"s3_max_pool_connections ({s3_max_pool_connections}) must be positive integer."
f"'s3_max_pool_connections' ({s3_max_pool_connections}) must be positive integer."
)
if error_msg:
raise AssetSyncError("Invalid value for configuration setting: " + error_msg)
raise AssetSyncError("Nonvalid value for configuration setting: " + error_msg)

def upload_assets(
self,
Expand Down
35 changes: 24 additions & 11 deletions test/unit/deadline_job_attachments/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,37 +1278,50 @@ def test_asset_uploader_constructor_with_non_integer_config_settings(
assert "Failed to parse configuration settings." in str(err.value)

@pytest.mark.parametrize(
"setting_name, invalid_value",
"setting_name, nonvalid_value, expected_error_msg",
[
pytest.param(
"s3_max_pool_connections",
"-100",
id="Invalid s3_max_pool_connections value: negative",
"'s3_max_pool_connections' (-100) must be positive integer.",
id="s3_max_pool_connections value is negative.",
),
pytest.param(
"s3_max_pool_connections",
"0",
id="Invalid s3_max_pool_connections value: 0",
"'s3_max_pool_connections' (0) must be positive integer.",
id="s3_max_pool_connections value is 0.",
),
pytest.param(
"s3_max_pool_connections",
"some string",
"Failed to parse configuration settings. Please ensure that the following settings in the config file are integers",
id="s3_max_pool_connections value is not a number.",
),
pytest.param(
"small_file_threshold_multiplier",
"-12",
id="Invalid small_file_threshold_multiplier value: negative",
"'small_file_threshold_multiplier' (-12) must be positive integer.",
id="small_file_threshold_multiplier value is negative.",
),
pytest.param(
"small_file_threshold_multiplier",
"some string",
"Failed to parse configuration settings. Please ensure that the following settings in the config file are integers",
id="small_file_threshold_multiplier value is not a number.",
),
],
)
def test_asset_uploader_constructor_with_invalid_config_settings(
self, setting_name, invalid_value, fresh_deadline_config
def test_asset_uploader_constructor_with_nonvalid_config_settings(
self, setting_name, nonvalid_value, expected_error_msg, fresh_deadline_config
):
"""
Tests that when the asset uploader is created with invalid config settings, an AssetSyncError is raised.
Tests that when the asset uploader is created with nonvalid config settings, an AssetSyncError is raised.
"""
config.set_setting(f"settings.{setting_name}", invalid_value)
config.set_setting(f"settings.{setting_name}", nonvalid_value)
with pytest.raises(AssetSyncError) as err:
_ = S3AssetUploader()
assert (
f"Invalid value for configuration setting: {setting_name} ({invalid_value}) must be positive integer."
) in str(err.value)
assert expected_error_msg in str(err.value)

@mock_sts
def test_file_already_uploaded_bucket_in_different_account(self):
Expand Down

0 comments on commit 148587a

Please sign in to comment.