Skip to content

Commit b871593

Browse files
committed
improve tests
1 parent 5e4e74c commit b871593

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

tests/aicore/unit/test_aicore.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ def test_set_config_custom_instance_name(self):
530530
mock_get_base_url.assert_called_with(instance_name)
531531

532532
# Verify instance_name was passed to all _get_secret calls
533-
for call in mock_get_secret.call_args_list:
534-
assert call[1].get("instance_name") == instance_name, (
535-
f"_get_secret call for {call[0][0]} missing instance_name={instance_name}"
533+
for c in mock_get_secret.call_args_list:
534+
assert c.kwargs.get("instance_name") == instance_name, (
535+
f"_get_secret call for {c.args[0]} missing instance_name={instance_name}"
536536
)
537537

538538
def test_set_config_calls_get_secret_with_correct_parameters(self):
@@ -547,30 +547,19 @@ def test_set_config_calls_get_secret_with_correct_parameters(self):
547547

548548
default_instance = "aicore-instance"
549549
# Verify _get_secret was called with correct parameters including instance_name
550-
calls = mock_get_secret.call_args_list
551-
assert any(
552-
call[0][0] == "AICORE_CLIENT_ID"
553-
and call[0][1] == "clientid"
554-
and call[1].get("instance_name") == default_instance
555-
for call in calls
550+
mock_get_secret.assert_any_call(
551+
"AICORE_CLIENT_ID", "clientid", instance_name=default_instance
556552
)
557-
assert any(
558-
call[0][0] == "AICORE_CLIENT_SECRET"
559-
and call[0][1] == "clientsecret"
560-
and call[1].get("instance_name") == default_instance
561-
for call in calls
553+
mock_get_secret.assert_any_call(
554+
"AICORE_CLIENT_SECRET", "clientsecret", instance_name=default_instance
562555
)
563-
assert any(
564-
call[0][0] == "AICORE_AUTH_URL"
565-
and call[0][1] == "url"
566-
and call[1].get("instance_name") == default_instance
567-
for call in calls
556+
mock_get_secret.assert_any_call(
557+
"AICORE_AUTH_URL", "url", instance_name=default_instance
568558
)
569-
assert any(
570-
call[0][0] == "AICORE_RESOURCE_GROUP"
571-
and call[1].get("default") == "default"
572-
and call[1].get("instance_name") == default_instance
573-
for call in calls
559+
mock_get_secret.assert_any_call(
560+
"AICORE_RESOURCE_GROUP",
561+
default="default",
562+
instance_name=default_instance,
574563
)
575564

576565
def test_set_config_logs_configuration(self):

0 commit comments

Comments
 (0)