def set_stack_properties(self, stack_properties: Optional[dict] = None) -> None: # TODO: get time to complete for complete stacks and % complete props: dict = stack_properties if stack_properties else {} self._timer.cancel() if not props: describe_stacks = self.client.describe_stacks props = describe_stacks(StackName=self.id)["Stacks"][0] iterable_props: List[Tuple[str, Callable]] = [ ("Parameters", Parameter), ("Outputs", Output), ("Tags", Tag), ] for prop_name, prop_class in iterable_props: for item in props.get(prop_name, []): item = prop_class(item) self._merge_props(getattr(self, prop_name.lower()), item) for key, value in props.items(): if key in [p[0] for p in iterable_props]: # noqa: C412 continue key = pascal_to_snake(key).replace("stack_", "") setattr(self, key, value) if self.status in StackStatus.IN_PROGRESS: self._timer = Timer( self._auto_refresh_interval.total_seconds(), self.refresh ) self._timer.start()
def test_pascal_to_snake(self): actual = pascal_to_snake("MyParam") self.assertEqual("my_param", actual) actual = pascal_to_snake("VPCParam") self.assertEqual("vpcparam", actual)