Skip to content

Commit

Permalink
address remaining comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cloutierMat committed Oct 15, 2024
1 parent 95e7611 commit 57a057b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion moto/utilities/id_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions tests/test_utilities/test_id_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -24,7 +24,7 @@ def generate_test_id(
existing_ids: ExistingIds = None,
tags: Tags = None,
):
return GENERATED_ID
return GENERIC_ID


class TestResourceIdentifier(ResourceIdentifier):
Expand All @@ -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):
Expand All @@ -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():
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 57a057b

Please sign in to comment.