diff --git a/skill/scripts/download_aws_icons.py b/skill/scripts/download_aws_icons.py index b40758ed..2170d388 100644 --- a/skill/scripts/download_aws_icons.py +++ b/skill/scripts/download_aws_icons.py @@ -94,6 +94,19 @@ def _classify_type(filename: str, zip_path: str) -> str: return "general" +def _is_target_entry(zip_path: str) -> bool: + """Return True if a ZIP entry is an icon variant we want to extract. + + Service / Resource / Category icons use the 48px size; Architecture + Group icons (e.g. AWS-Cloud-logo, Region, VPC) use 32px. + """ + if not zip_path.endswith(".svg"): + return False + if "Architecture-Group-Icons" in zip_path: + return "_32" in zip_path + return "_48" in zip_path + + def _name_from_filename(filename: str) -> str: """Extract human-readable name from icon filename. @@ -159,10 +172,7 @@ def main() -> None: for info in zf.infolist(): if info.is_dir(): continue - # Only extract 48px SVGs (standard size) - if not info.filename.endswith(".svg"): - continue - if "_48" not in info.filename: + if not _is_target_entry(info.filename): continue filename = Path(info.filename).name diff --git a/tests/test_download_aws_icons.py b/tests/test_download_aws_icons.py new file mode 100644 index 00000000..970cda46 --- /dev/null +++ b/tests/test_download_aws_icons.py @@ -0,0 +1,63 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: MIT-0 +"""Tests for scripts.download_aws_icons — ZIP filtering and classification.""" + +from scripts.download_aws_icons import _classify_type, _is_target_entry + + +class TestIsTargetEntry: + def test_service_48_extracted(self): + assert _is_target_entry("Architecture-Service-Icons_01302026/Arch_Compute/48/Arch_AWS-Lambda_48.svg") + + def test_resource_48_extracted(self): + assert _is_target_entry("Resource-Icons_01302026/Res_Compute/Res_AWS-Lambda_48_Light.svg") + + def test_category_48_extracted(self): + assert _is_target_entry("Architecture-Category-Icons_01302026/Arch-Category_Compute_48.svg") + + def test_group_32_extracted(self): + assert _is_target_entry("Architecture-Group-Icons_01302026/AWS-Cloud-logo_32.svg") + + def test_group_32_dark_variant_extracted(self): + assert _is_target_entry("Architecture-Group-Icons_01302026/AWS-Cloud-logo_32_Dark.svg") + + def test_group_48_not_extracted(self): + # Group icons live at 32px only; reject any stray 48 in the group dir. + assert not _is_target_entry("Architecture-Group-Icons_01302026/AWS-Cloud-logo_48.svg") + + def test_service_32_not_extracted(self): + # Service icons live at 48px in this script; reject 32 in non-group dirs. + assert not _is_target_entry("Architecture-Service-Icons_01302026/Arch_Compute/32/Arch_AWS-Lambda_32.svg") + + def test_non_svg_not_extracted(self): + assert not _is_target_entry("Architecture-Group-Icons_01302026/AWS-Cloud-logo_32.png") + + +class TestClassifyType: + def test_group_path_classified_as_group(self): + result = _classify_type( + "AWS-Cloud-logo_32.svg", + "Architecture-Group-Icons_01302026/AWS-Cloud-logo_32.svg", + ) + assert result == "group" + + def test_service_classified_as_service(self): + result = _classify_type( + "Arch_AWS-Lambda_48.svg", + "Architecture-Service-Icons_01302026/Arch_Compute/48/Arch_AWS-Lambda_48.svg", + ) + assert result == "service" + + def test_resource_classified_as_resource(self): + result = _classify_type( + "Res_AWS-Lambda_48_Light.svg", + "Resource-Icons_01302026/Res_Compute/Res_AWS-Lambda_48_Light.svg", + ) + assert result == "resource" + + def test_category_classified_as_category(self): + result = _classify_type( + "Arch-Category_Compute_48.svg", + "Architecture-Category-Icons_01302026/Arch-Category_Compute_48.svg", + ) + assert result == "category"