From 57a057b8b442fc181b140fbfec2e80d43bfbab4a Mon Sep 17 00:00:00 2001 From: Mathieu Cloutier Date: Mon, 14 Oct 2024 19:39:52 -0600 Subject: [PATCH] address remaining comments --- moto/utilities/id_generator.py | 3 ++- tests/test_utilities/test_id_generator.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/moto/utilities/id_generator.py b/moto/utilities/id_generator.py index 329d2ec37ac2..a26464a43cc9 100644 --- a/moto/utilities/id_generator.py +++ b/moto/utilities/id_generator.py @@ -71,7 +71,8 @@ def __init__(self) -> None: def get_custom_id( self, resource_identifier: ResourceIdentifier ) -> Union[str, None]: - # retrieves a custom_id for a resource. Returns None + # retrieves a custom_id for a resource. Returns None if no id were registered + # that matches the `resource_identifier` return self._custom_ids.get(resource_identifier.unique_identifier) def set_custom_id( diff --git a/tests/test_utilities/test_id_generator.py b/tests/test_utilities/test_id_generator.py index 7ee85fd32f3f..45ff2a0439f9 100644 --- a/tests/test_utilities/test_id_generator.py +++ b/tests/test_utilities/test_id_generator.py @@ -12,7 +12,7 @@ RESOURCE_NAME = "my-resource" CUSTOM_ID = "custom" -GENERATED_ID = "generated" +GENERIC_ID = "generated" TAG_ID = "fromTag" SERVICE = "test-service" RESOURCE = "test-resource" @@ -24,7 +24,7 @@ def generate_test_id( existing_ids: ExistingIds = None, tags: Tags = None, ): - return GENERATED_ID + return GENERIC_ID class TestResourceIdentifier(ResourceIdentifier): @@ -39,7 +39,7 @@ def generate(self, existing_ids: ExistingIds = None, tags: Tags = None) -> str: def test_generate_with_no_resource_identifier(): generated_id = generate_test_id(None) - assert generated_id == GENERATED_ID + assert generated_id == GENERIC_ID def test_generate_with_matching_resource_identifier(set_custom_id): @@ -58,7 +58,7 @@ def test_generate_with_non_matching_resource_identifier(set_custom_id): set_custom_id(resource_identifier, CUSTOM_ID) generated_id = generate_test_id(resource_identifier=resource_identifier_2) - assert generated_id == GENERATED_ID + assert generated_id == GENERIC_ID def test_generate_with_custom_id_tag(): @@ -87,7 +87,7 @@ def test_generate_with_existing_id(set_custom_id): generated_id = generate_test_id( resource_identifier=resource_identifier, existing_ids=[CUSTOM_ID] ) - assert generated_id == GENERATED_ID + assert generated_id == GENERIC_ID def test_generate_with_tags_and_existing_id(set_custom_id): @@ -98,7 +98,7 @@ def test_generate_with_tags_and_existing_id(set_custom_id): existing_ids=[TAG_ID], tags={TAG_KEY_CUSTOM_ID: TAG_ID}, ) - assert generated_id == GENERATED_ID + assert generated_id == GENERIC_ID def test_generate_with_tags_fallback(set_custom_id):