From ca08cfade9a8667a0df4b2d4b841fd16e4ce9dce Mon Sep 17 00:00:00 2001 From: PrzeG Date: Wed, 6 Mar 2024 12:51:06 +0100 Subject: [PATCH] Pre-commit changes --- .../models/cisco_secure_internet_gateway.py | 16 ++++++++++++---- .../test_find_template_values.py | 7 ++----- .../feature_template/find_template_values.py | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/catalystwan/api/templates/models/cisco_secure_internet_gateway.py b/catalystwan/api/templates/models/cisco_secure_internet_gateway.py index 71b01362..b7bf6e20 100644 --- a/catalystwan/api/templates/models/cisco_secure_internet_gateway.py +++ b/catalystwan/api/templates/models/cisco_secure_internet_gateway.py @@ -81,8 +81,12 @@ class Interface(FeatureTemplateValidator): description: Optional[str] = None unnumbered: bool = True address: Optional[ipaddress.IPv4Interface] = None - tunnel_source: Optional[ipaddress.IPv4Address] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-source"}) - tunnel_source_interface: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-source-interface"}) + tunnel_source: Optional[ipaddress.IPv4Address] = Field( + default=None, json_schema_extra={"vmanage_key": "tunnel-source"} + ) + tunnel_source_interface: Optional[str] = Field( + default=None, json_schema_extra={"vmanage_key": "tunnel-source-interface"} + ) tunnel_route_via: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-route-via"}) tunnel_destination: str = Field(json_schema_extra={"vmanage_key": "tunnel-destination"}) application: Application = Application.SIG @@ -157,7 +161,9 @@ class RefreshTimeUnit(str, Enum): class Service(FeatureTemplateValidator): svc_type: SvcType = Field(SvcType.SIG, json_schema_extra={"vmanage_key": "svc-type"}) - interface_pair: List[InterfacePair] = Field(json_schema_extra={"data_path": ["ha-pairs"], "vmanage_key": "interface-pair"}) + interface_pair: List[InterfacePair] = Field( + json_schema_extra={"data_path": ["ha-pairs"], "vmanage_key": "interface-pair"} + ) auth_required: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "auth-required"}) xff_forward_enabled: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "xff-forward-enabled"}) ofw_enabled: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "ofw-enabled"}) @@ -208,7 +214,9 @@ class CiscoSecureInternetGatewayModel(FeatureTemplate): vpn_id: int = Field(DEFAULT_SIG_VPN_ID, json_schema_extra={"vmanage_key": "vpn-id"}) interface: List[Interface] service: List[Service] - tracker_src_ip: Optional[ipaddress.IPv4Interface] = Field(default=None, json_schema_extra={"vmanage_key": "tracker-src-ip"}) + tracker_src_ip: Optional[ipaddress.IPv4Interface] = Field( + default=None, json_schema_extra={"vmanage_key": "tracker-src-ip"} + ) tracker: Optional[List[Tracker]] = None payload_path: ClassVar[Path] = Path(__file__).parent / "DEPRECATED" diff --git a/catalystwan/integration_tests/test_find_template_values.py b/catalystwan/integration_tests/test_find_template_values.py index ead2692d..b650ecd1 100644 --- a/catalystwan/integration_tests/test_find_template_values.py +++ b/catalystwan/integration_tests/test_find_template_values.py @@ -1,10 +1,7 @@ +import json import os import unittest from typing import Any, List, cast -import json - -from pydantic import ValidationError -from catalystwan.exceptions import TemplateTypeError from catalystwan.session import create_manager_session from catalystwan.utils.feature_template.find_template_values import find_template_values @@ -19,7 +16,7 @@ def setUp(self) -> None: password=cast(str, os.environ.get("TEST_VMANAGE_PASSWORD")), ) self.templates = self.session.api.templates._get_feature_templates(summary=False) - + def test_find_template_value(self): for template in self.templates: definition = json.loads(template.template_definiton) diff --git a/catalystwan/utils/feature_template/find_template_values.py b/catalystwan/utils/feature_template/find_template_values.py index d281859e..7df7bea6 100644 --- a/catalystwan/utils/feature_template/find_template_values.py +++ b/catalystwan/utils/feature_template/find_template_values.py @@ -57,7 +57,7 @@ def find_template_values( else: current_nesting[field_key].append(find_template_values(item, device_specific_variables)) else: - current_nesting[field_key].append(item) + current_nesting[field_key].append(item) elif template_definition["vipObjectType"] != "tree": current_nesting = get_nested_dict(templated_values, path[:-1]) current_nesting[field_key] = template_value