From 505ddb2272937ba678f1423f2b34e8aeb9a6b37a Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 4 Dec 2024 17:12:50 +0000 Subject: [PATCH] fix mypy and tests --- plugins/gcp/test/test_collector.py | 2 ++ plugins/gcp/test/test_scc.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/gcp/test/test_collector.py b/plugins/gcp/test/test_collector.py index 3dfb5e5c8..66c078d9e 100644 --- a/plugins/gcp/test/test_collector.py +++ b/plugins/gcp/test/test_collector.py @@ -90,6 +90,8 @@ def all_base_classes(cls: Type[Any]) -> Set[Type[Any]]: expected_declared_properties = ["kind", "_kind_display"] expected_props_in_hierarchy = ["_kind_service", "_metadata"] for rc in all_resources: + if not rc._model_export: + continue for prop in expected_declared_properties: assert prop in rc.__dict__, f"{rc.__name__} missing {prop}" with_bases = (all_base_classes(rc) | {rc}) - {GcpResource, BaseResource} diff --git a/plugins/gcp/test/test_scc.py b/plugins/gcp/test/test_scc.py index 009a1c86c..b5aba7583 100644 --- a/plugins/gcp/test/test_scc.py +++ b/plugins/gcp/test/test_scc.py @@ -7,13 +7,12 @@ from .random_client import roundtrip -class DefaultDict(dict): - # for random location name we use the default global location - def __init__(self, default_value: Any, *args, **kwargs): +class DefaultDict(dict): # type: ignore + def __init__(self, default_value: Any, *args: Any, **kwargs: Any): super().__init__(*args, **kwargs) self.default_value = default_value - def get(self, key, default=None): + def get(self, key: str, default: Any = None): if key in self: return super().get(key, default) return self.default_value @@ -21,6 +20,7 @@ def get(self, key, default=None): def test_gcp_scc_findings(random_builder: GraphBuilder) -> None: firewall = roundtrip(GcpFirewall, random_builder) + # for random location name we will use the default global location random_builder.region_by_name = DefaultDict(random_builder.fallback_global_region) GcpSccFinding.collect_resources(random_builder)