From a8a7e9434a5c84fc0463d12ae3a50ba6090412bf Mon Sep 17 00:00:00 2001 From: "Georgios P. Katsikas" Date: Sat, 9 Nov 2024 11:29:18 +0000 Subject: [PATCH] chore: remove unecessary imports and add comment in _Driver --- src/device/service/driver_api/_Driver.py | 2 ++ src/tests/p4-fwd-l1/tests/Objects.py | 12 +++--------- .../p4-fwd-l1/tests/test_functional_bootstrap.py | 7 +------ .../p4-fwd-l1/tests/test_functional_cleanup.py | 11 +++-------- .../tests/test_functional_create_service.py | 14 +++----------- .../tests/test_functional_delete_service.py | 10 ++-------- 6 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/device/service/driver_api/_Driver.py b/src/device/service/driver_api/_Driver.py index 2580c3e78..f17004d24 100644 --- a/src/device/service/driver_api/_Driver.py +++ b/src/device/service/driver_api/_Driver.py @@ -31,6 +31,8 @@ class _Driver: def __init__(self, name : str, address: str, port: int, **settings) -> None: """ Initialize Driver. Parameters: + name : str + Device driver name address : str The address of the device port : int diff --git a/src/tests/p4-fwd-l1/tests/Objects.py b/src/tests/p4-fwd-l1/tests/Objects.py index ba260e936..83d1e23b4 100644 --- a/src/tests/p4-fwd-l1/tests/Objects.py +++ b/src/tests/p4-fwd-l1/tests/Objects.py @@ -13,18 +13,12 @@ # limitations under the License. import os -from typing import Dict, List, Tuple from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( - json_device_connect_rules, json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, - json_device_connect_rules, json_device_id, json_device_p4_disabled, - json_device_emulated_tapi_disabled, json_device_id, json_device_packetrouter_disabled, json_device_tapi_disabled) -from common.tools.object_factory.Service import ( - get_service_uuid, json_service_l3nm_planned,json_service_p4_planned) -from common.tools.object_factory.ConfigRule import ( - json_config_rule_set, json_config_rule_delete) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_ids, json_endpoints, json_endpoint_id + json_device_connect_rules, json_device_id, json_device_p4_disabled) +from common.tools.object_factory.Service import get_service_uuid, json_service_p4_planned +from common.tools.object_factory.EndPoint import json_endpoint_ids, json_endpoints from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id diff --git a/src/tests/p4-fwd-l1/tests/test_functional_bootstrap.py b/src/tests/p4-fwd-l1/tests/test_functional_bootstrap.py index fe622c908..341799c02 100644 --- a/src/tests/p4-fwd-l1/tests/test_functional_bootstrap.py +++ b/src/tests/p4-fwd-l1/tests/test_functional_bootstrap.py @@ -14,14 +14,9 @@ import copy, logging, pytest from common.Settings import get_setting -from common.tests.EventTools import EVENT_CREATE, EVENT_UPDATE, check_events from common.tools.object_factory.Context import json_context_id -from common.tools.object_factory.Device import json_device_id -from common.tools.object_factory.Link import json_link_id -from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient -from context.client.EventsCollector import EventsCollector -from common.proto.context_pb2 import ConfigActionEnum, Context, ContextId, Device, Empty, Link, Topology, DeviceOperationalStatusEnum +from common.proto.context_pb2 import Context, ContextId, Device, Empty, Link, Topology, DeviceOperationalStatusEnum from device.client.DeviceClient import DeviceClient from .Objects import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES diff --git a/src/tests/p4-fwd-l1/tests/test_functional_cleanup.py b/src/tests/p4-fwd-l1/tests/test_functional_cleanup.py index 67934ff8a..0b44f794d 100644 --- a/src/tests/p4-fwd-l1/tests/test_functional_cleanup.py +++ b/src/tests/p4-fwd-l1/tests/test_functional_cleanup.py @@ -12,18 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import copy, logging, pytest +import logging, pytest from common.Settings import get_setting -from common.tests.EventTools import EVENT_REMOVE, check_events from common.tools.object_factory.Context import json_context_id -from common.tools.object_factory.Device import json_device_id -from common.tools.object_factory.Link import json_link_id -from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient -from context.client.EventsCollector import EventsCollector -from common.proto.context_pb2 import ConfigActionEnum, ContextId, Device, DeviceId, Empty, Link, LinkId, TopologyId, DeviceOperationalStatusEnum +from common.proto.context_pb2 import ContextId, DeviceId, Empty, LinkId, TopologyId from device.client.DeviceClient import DeviceClient -from .Objects import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES +from .Objects import CONTEXTS, DEVICES, LINKS, TOPOLOGIES LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) diff --git a/src/tests/p4-fwd-l1/tests/test_functional_create_service.py b/src/tests/p4-fwd-l1/tests/test_functional_create_service.py index 9f82da129..ee714c477 100644 --- a/src/tests/p4-fwd-l1/tests/test_functional_create_service.py +++ b/src/tests/p4-fwd-l1/tests/test_functional_create_service.py @@ -14,24 +14,16 @@ import copy, logging, pytest from common.Settings import get_setting -from common.tests.EventTools import EVENT_CREATE, EVENT_UPDATE, check_events -from common.tools.object_factory.Context import json_context_id -from common.tools.object_factory.Device import json_device_id -from common.tools.object_factory.Service import json_service_id -from common.tools.object_factory.Link import json_link_id -from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient -from context.client.EventsCollector import EventsCollector -from common.proto.context_pb2 import Context, ContextId, Device, Empty, Link, Topology, Service, ServiceId +from common.proto.context_pb2 import Service from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient -from tests.p4.tests.Objects import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, SERVICES -from common.proto.context_pb2 import ConfigActionEnum, Device, DeviceId,\ - DeviceOperationalStatusEnum +from tests.p4.tests.Objects import SERVICES LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) + @pytest.fixture(scope='session') def context_client(): _client = ContextClient(get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC')) diff --git a/src/tests/p4-fwd-l1/tests/test_functional_delete_service.py b/src/tests/p4-fwd-l1/tests/test_functional_delete_service.py index 98b6a01c1..439a88efd 100644 --- a/src/tests/p4-fwd-l1/tests/test_functional_delete_service.py +++ b/src/tests/p4-fwd-l1/tests/test_functional_delete_service.py @@ -14,18 +14,12 @@ import copy, logging, pytest from common.Settings import get_setting -from common.tests.EventTools import EVENT_REMOVE, check_events -from common.tools.object_factory.Context import json_context_id -from common.tools.object_factory.Device import json_device_id from common.tools.object_factory.Service import json_service_id -from common.tools.object_factory.Link import json_link_id -from common.tools.object_factory.Topology import json_topology_id from context.client.ContextClient import ContextClient -from context.client.EventsCollector import EventsCollector -from common.proto.context_pb2 import ConfigActionEnum, ContextId, Device, DeviceId, Empty, LinkId, TopologyId, Service, ServiceId, DeviceOperationalStatusEnum +from common.proto.context_pb2 import ServiceId from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient -from .Objects import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, SERVICES +from .Objects import CONTEXT_ID, SERVICES LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) -- GitLab