added some type hinting with tests to help in refactoring in the future

This commit is contained in:
Blake Harnden 2020-05-24 23:37:38 -07:00
parent 964f78f06a
commit ba8b16ec34
11 changed files with 199 additions and 156 deletions

View file

@ -39,7 +39,7 @@ class ServiceDependencies:
that all services will be booted and that all dependencies exist within the services provided.
"""
def __init__(self, services: List["CoreService"]) -> None:
def __init__(self, services: List[Type["CoreService"]]) -> None:
# helpers to check validity
self.dependents = {}
self.booted = set()

View file

@ -8,6 +8,7 @@ from core.config import (
)
from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emulator.enumerations import ConfigDataTypes
from core.emulator.session import Session
from core.location.mobility import BasicRangeModel
from core.nodes.network import WlanNode
@ -41,7 +42,7 @@ class TestConf:
def test_nodes(self):
# given
config_manager = ConfigurableManager()
test_config = {1: 2}
test_config = {"1": "2"}
node_id = 1
config_manager.set_configs(test_config)
config_manager.set_configs(test_config, node_id=node_id)
@ -56,7 +57,7 @@ class TestConf:
def test_config_reset_all(self):
# given
config_manager = ConfigurableManager()
test_config = {1: 2}
test_config = {"1": "2"}
node_id = 1
config_manager.set_configs(test_config)
config_manager.set_configs(test_config, node_id=node_id)
@ -70,7 +71,7 @@ class TestConf:
def test_config_reset_node(self):
# given
config_manager = ConfigurableManager()
test_config = {1: 2}
test_config = {"1": "2"}
node_id = 1
config_manager.set_configs(test_config)
config_manager.set_configs(test_config, node_id=node_id)
@ -85,7 +86,7 @@ class TestConf:
def test_configs_setget(self):
# given
config_manager = ConfigurableManager()
test_config = {1: 2}
test_config = {"1": "2"}
node_id = 1
config_manager.set_configs(test_config)
config_manager.set_configs(test_config, node_id=node_id)
@ -146,7 +147,7 @@ class TestConf:
with pytest.raises(ValueError):
manager.get_model_config(1, bad_name)
def test_model_set(self, session):
def test_model_set(self, session: Session):
# given
wlan_node = session.add_node(WlanNode)
@ -156,7 +157,7 @@ class TestConf:
# then
assert session.mobility.get_model_config(wlan_node.id, BasicRangeModel.name)
def test_model_set_error(self, session):
def test_model_set_error(self, session: Session):
# given
wlan_node = session.add_node(WlanNode)
@ -164,7 +165,7 @@ class TestConf:
with pytest.raises(ValueError):
session.mobility.set_model(wlan_node, EmaneIeee80211abgModel)
def test_get_models(self, session):
def test_get_models(self, session: Session):
# given
wlan_node = session.add_node(WlanNode)
session.mobility.set_model(wlan_node, BasicRangeModel)

View file

@ -7,8 +7,9 @@ import threading
import pytest
from core.emulator.emudata import NodeOptions
from core.emulator.emudata import IpPrefixes, NodeOptions
from core.emulator.enumerations import MessageFlags
from core.emulator.session import Session
from core.errors import CoreCommandError
from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility
from core.nodes.base import CoreNode
@ -59,7 +60,7 @@ class TestCore:
status = ping(node_one, node_two, ip_prefixes)
assert not status
def test_vnode_client(self, request, session, ip_prefixes):
def test_vnode_client(self, request, session: Session, ip_prefixes: IpPrefixes):
"""
Test vnode client methods.
@ -92,7 +93,7 @@ class TestCore:
if not request.config.getoption("mock"):
assert client.check_cmd("echo hello") == "hello"
def test_netif(self, session, ip_prefixes):
def test_netif(self, session: Session, ip_prefixes: IpPrefixes):
"""
Test netif methods.
@ -123,8 +124,8 @@ class TestCore:
assert node_two.commonnets(node_one)
# check we can retrieve netif index
assert node_one.getifindex(0)
assert node_two.getifindex(0)
assert node_one.ifname(0)
assert node_two.ifname(0)
# check interface parameters
interface = node_one.netif(0)
@ -136,7 +137,7 @@ class TestCore:
node_one.delnetif(0)
assert not node_one.netif(0)
def test_wlan_ping(self, session, ip_prefixes):
def test_wlan_ping(self, session: Session, ip_prefixes: IpPrefixes):
"""
Test basic wlan network.
@ -166,7 +167,7 @@ class TestCore:
status = ping(node_one, node_two, ip_prefixes)
assert not status
def test_mobility(self, session, ip_prefixes):
def test_mobility(self, session: Session, ip_prefixes: IpPrefixes):
"""
Test basic wlan network.

View file

@ -1,10 +1,11 @@
from core.emulator.emudata import NodeOptions
from core.emulator.session import Session
from core.nodes.base import CoreNode
from core.nodes.network import HubNode
class TestDistributed:
def test_remote_node(self, session):
def test_remote_node(self, session: Session):
# given
server_name = "core2"
host = "127.0.0.1"
@ -21,7 +22,7 @@ class TestDistributed:
assert node.server.name == server_name
assert node.server.host == host
def test_remote_bridge(self, session):
def test_remote_bridge(self, session: Session):
# given
server_name = "core2"
host = "127.0.0.1"

View file

@ -1,5 +1,7 @@
import time
from queue import Queue
from tempfile import TemporaryFile
from typing import Optional
import grpc
import pytest
@ -9,6 +11,7 @@ from core.api.grpc import core_pb2
from core.api.grpc.client import CoreGrpcClient, InterfaceHelper
from core.api.grpc.emane_pb2 import EmaneModelConfig
from core.api.grpc.mobility_pb2 import MobilityAction, MobilityConfig
from core.api.grpc.server import CoreGrpcServer
from core.api.grpc.services_pb2 import ServiceAction, ServiceConfig, ServiceFileConfig
from core.api.grpc.wlan_pb2 import WlanConfig
from core.api.tlv.dataconversion import ConfigShim
@ -16,7 +19,7 @@ from core.api.tlv.enumerations import ConfigFlags
from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emane.nodes import EmaneNet
from core.emulator.data import EventData
from core.emulator.emudata import NodeOptions
from core.emulator.emudata import IpPrefixes, NodeOptions
from core.emulator.enumerations import EventTypes, ExceptionLevels, NodeTypes
from core.errors import CoreError
from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility
@ -26,7 +29,7 @@ from core.xml.corexml import CoreXmlWriter
class TestGrpc:
def test_start_session(self, grpc_server):
def test_start_session(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -159,7 +162,9 @@ class TestGrpc:
assert service_file.data == service_file_config.data
@pytest.mark.parametrize("session_id", [None, 6013])
def test_create_session(self, grpc_server, session_id):
def test_create_session(
self, grpc_server: CoreGrpcServer, session_id: Optional[int]
):
# given
client = CoreGrpcClient()
@ -178,7 +183,9 @@ class TestGrpc:
assert session.id == session_id
@pytest.mark.parametrize("session_id, expected", [(None, True), (6013, False)])
def test_delete_session(self, grpc_server, session_id, expected):
def test_delete_session(
self, grpc_server: CoreGrpcServer, session_id: Optional[int], expected: bool
):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -193,7 +200,7 @@ class TestGrpc:
assert response.result is expected
assert grpc_server.coreemu.sessions.get(session_id) is None
def test_get_session(self, grpc_server):
def test_get_session(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -209,7 +216,7 @@ class TestGrpc:
assert len(response.session.nodes) == 1
assert len(response.session.links) == 0
def test_get_sessions(self, grpc_server):
def test_get_sessions(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -227,7 +234,7 @@ class TestGrpc:
assert len(response.sessions) == 1
assert found_session is not None
def test_get_session_options(self, grpc_server):
def test_get_session_options(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -239,7 +246,7 @@ class TestGrpc:
# then
assert len(response.config) > 0
def test_get_session_location(self, grpc_server):
def test_get_session_location(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -257,7 +264,7 @@ class TestGrpc:
assert response.location.lon == 0
assert response.location.alt == 0
def test_set_session_location(self, grpc_server):
def test_set_session_location(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -284,7 +291,7 @@ class TestGrpc:
assert session.location.refscale == scale
assert session.location.refgeo == lat_lon_alt
def test_set_session_options(self, grpc_server):
def test_set_session_options(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -301,7 +308,7 @@ class TestGrpc:
config = session.options.get_configs()
assert len(config) > 0
def test_set_session_metadata(self, grpc_server):
def test_set_session_metadata(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -316,7 +323,7 @@ class TestGrpc:
assert response.result is True
assert session.metadata[key] == value
def test_get_session_metadata(self, grpc_server):
def test_get_session_metadata(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -331,7 +338,7 @@ class TestGrpc:
# then
assert response.config[key] == value
def test_set_session_state(self, grpc_server):
def test_set_session_state(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -346,7 +353,7 @@ class TestGrpc:
assert response.result is True
assert session.state == EventTypes.DEFINITION_STATE
def test_add_node(self, grpc_server):
def test_add_node(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -360,7 +367,7 @@ class TestGrpc:
assert response.node_id is not None
assert session.get_node(response.node_id, CoreNode) is not None
def test_get_node(self, grpc_server):
def test_get_node(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -373,7 +380,7 @@ class TestGrpc:
# then
assert response.node.id == node.id
def test_edit_node(self, grpc_server):
def test_edit_node(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -391,7 +398,9 @@ class TestGrpc:
assert node.position.y == y
@pytest.mark.parametrize("node_id, expected", [(1, True), (2, False)])
def test_delete_node(self, grpc_server, node_id, expected):
def test_delete_node(
self, grpc_server: CoreGrpcServer, node_id: int, expected: bool
):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -407,7 +416,7 @@ class TestGrpc:
with pytest.raises(CoreError):
assert session.get_node(node.id, CoreNode)
def test_node_command(self, request, grpc_server):
def test_node_command(self, request, grpc_server: CoreGrpcServer):
if request.config.getoption("mock"):
pytest.skip("mocking calls")
@ -428,7 +437,7 @@ class TestGrpc:
# then
assert response.output == output
def test_get_node_terminal(self, grpc_server):
def test_get_node_terminal(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -444,7 +453,7 @@ class TestGrpc:
# then
assert response.terminal is not None
def test_get_hooks(self, grpc_server):
def test_get_hooks(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -463,7 +472,7 @@ class TestGrpc:
assert hook.file == file_name
assert hook.data == file_data
def test_add_hook(self, grpc_server):
def test_add_hook(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -479,7 +488,7 @@ class TestGrpc:
# then
assert response.result is True
def test_save_xml(self, grpc_server, tmpdir):
def test_save_xml(self, grpc_server: CoreGrpcServer, tmpdir: TemporaryFile):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -492,7 +501,7 @@ class TestGrpc:
# then
assert tmp.exists()
def test_open_xml_hook(self, grpc_server, tmpdir):
def test_open_xml_hook(self, grpc_server: CoreGrpcServer, tmpdir: TemporaryFile):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -507,7 +516,7 @@ class TestGrpc:
assert response.result is True
assert response.session_id is not None
def test_get_node_links(self, grpc_server, ip_prefixes):
def test_get_node_links(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -523,7 +532,9 @@ class TestGrpc:
# then
assert len(response.links) == 1
def test_get_node_links_exception(self, grpc_server, ip_prefixes):
def test_get_node_links_exception(
self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes
):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -537,7 +548,9 @@ class TestGrpc:
with client.context_connect():
client.get_node_links(session.id, 3)
def test_add_link(self, grpc_server, interface_helper):
def test_add_link(
self, grpc_server: CoreGrpcServer, interface_helper: InterfaceHelper
):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -554,7 +567,9 @@ class TestGrpc:
assert response.result is True
assert len(switch.all_link_data()) == 1
def test_add_link_exception(self, grpc_server, interface_helper):
def test_add_link_exception(
self, grpc_server: CoreGrpcServer, interface_helper: InterfaceHelper
):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -566,7 +581,7 @@ class TestGrpc:
with client.context_connect():
client.add_link(session.id, 1, 3, interface)
def test_edit_link(self, grpc_server, ip_prefixes):
def test_edit_link(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -589,7 +604,7 @@ class TestGrpc:
link = switch.all_link_data()[0]
assert options.bandwidth == link.bandwidth
def test_delete_link(self, grpc_server, ip_prefixes):
def test_delete_link(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -616,7 +631,7 @@ class TestGrpc:
assert response.result is True
assert len(link_node.all_link_data(0)) == 0
def test_get_wlan_config(self, grpc_server):
def test_get_wlan_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -629,7 +644,7 @@ class TestGrpc:
# then
assert len(response.config) > 0
def test_set_wlan_config(self, grpc_server):
def test_set_wlan_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -661,7 +676,7 @@ class TestGrpc:
assert config[range_key] == range_value
assert wlan.model.range == int(range_value)
def test_get_emane_config(self, grpc_server):
def test_get_emane_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -673,7 +688,7 @@ class TestGrpc:
# then
assert len(response.config) > 0
def test_set_emane_config(self, grpc_server):
def test_set_emane_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -690,7 +705,7 @@ class TestGrpc:
assert len(config) > 1
assert config[config_key] == config_value
def test_get_emane_model_configs(self, grpc_server):
def test_get_emane_model_configs(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -717,7 +732,7 @@ class TestGrpc:
assert len(model_config.config) > 0
assert model_config.interface == -1
def test_set_emane_model_config(self, grpc_server):
def test_set_emane_model_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -745,7 +760,7 @@ class TestGrpc:
)
assert config[config_key] == config_value
def test_get_emane_model_config(self, grpc_server):
def test_get_emane_model_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -764,7 +779,7 @@ class TestGrpc:
# then
assert len(response.config) > 0
def test_get_emane_models(self, grpc_server):
def test_get_emane_models(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -776,7 +791,7 @@ class TestGrpc:
# then
assert len(response.models) > 0
def test_get_mobility_configs(self, grpc_server):
def test_get_mobility_configs(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -793,7 +808,7 @@ class TestGrpc:
mapped_config = response.configs[wlan.id]
assert len(mapped_config.config) > 0
def test_get_mobility_config(self, grpc_server):
def test_get_mobility_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -807,7 +822,7 @@ class TestGrpc:
# then
assert len(response.config) > 0
def test_set_mobility_config(self, grpc_server):
def test_set_mobility_config(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -826,7 +841,7 @@ class TestGrpc:
config = session.mobility.get_model_config(wlan.id, Ns2ScriptedMobility.name)
assert config[config_key] == config_value
def test_mobility_action(self, grpc_server):
def test_mobility_action(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -841,7 +856,7 @@ class TestGrpc:
# then
assert response.result is True
def test_get_services(self, grpc_server):
def test_get_services(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
@ -852,7 +867,7 @@ class TestGrpc:
# then
assert len(response.services) > 0
def test_get_service_defaults(self, grpc_server):
def test_get_service_defaults(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -864,7 +879,7 @@ class TestGrpc:
# then
assert len(response.defaults) > 0
def test_set_service_defaults(self, grpc_server):
def test_set_service_defaults(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -879,7 +894,7 @@ class TestGrpc:
assert response.result is True
assert session.services.default_services[node_type] == services
def test_get_node_service_configs(self, grpc_server):
def test_get_node_service_configs(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -897,7 +912,7 @@ class TestGrpc:
assert service_config.node_id == node.id
assert service_config.service == service_name
def test_get_node_service(self, grpc_server):
def test_get_node_service(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -910,7 +925,7 @@ class TestGrpc:
# then
assert len(response.service.configs) > 0
def test_get_node_service_file(self, grpc_server):
def test_get_node_service_file(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -925,7 +940,7 @@ class TestGrpc:
# then
assert response.data is not None
def test_set_node_service(self, grpc_server):
def test_set_node_service(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -946,7 +961,7 @@ class TestGrpc:
)
assert service.validate == tuple(validate)
def test_set_node_service_file(self, grpc_server):
def test_set_node_service_file(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -966,7 +981,7 @@ class TestGrpc:
service_file = session.services.get_service_file(node, service_name, file_name)
assert service_file.data == file_data
def test_service_action(self, grpc_server):
def test_service_action(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -982,7 +997,7 @@ class TestGrpc:
# then
assert response.result is True
def test_node_events(self, grpc_server):
def test_node_events(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -1003,7 +1018,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_link_events(self, grpc_server, ip_prefixes):
def test_link_events(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -1028,7 +1043,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_throughputs(self, request, grpc_server):
def test_throughputs(self, request, grpc_server: CoreGrpcServer):
if request.config.getoption("mock"):
pytest.skip("mocking calls")
@ -1049,7 +1064,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_session_events(self, grpc_server):
def test_session_events(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -1072,7 +1087,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_config_events(self, grpc_server):
def test_config_events(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -1096,7 +1111,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_exception_events(self, grpc_server):
def test_exception_events(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
@ -1125,7 +1140,7 @@ class TestGrpc:
# then
queue.get(timeout=5)
def test_file_events(self, grpc_server):
def test_file_events(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()

View file

@ -3,6 +3,7 @@ Tests for testing tlv message handling.
"""
import os
import time
from typing import Optional
import mock
import netaddr
@ -10,6 +11,7 @@ import pytest
from mock import MagicMock
from core.api.tlv import coreapi
from core.api.tlv.corehandlers import CoreHandler
from core.api.tlv.enumerations import (
ConfigFlags,
ConfigTlvs,
@ -28,7 +30,7 @@ from core.nodes.base import CoreNode, NodeBase
from core.nodes.network import SwitchNode, WlanNode
def dict_to_str(values):
def dict_to_str(values) -> str:
return "|".join(f"{x}={values[x]}" for x in values)
@ -44,7 +46,9 @@ class TestGui:
(NodeTypes.TUNNEL, None),
],
)
def test_node_add(self, coretlv, node_type, model):
def test_node_add(
self, coretlv: CoreHandler, node_type: NodeTypes, model: Optional[str]
):
node_id = 1
message = coreapi.CoreNodeMessage.create(
MessageFlags.ADD.value,
@ -61,7 +65,7 @@ class TestGui:
coretlv.handle_message(message)
assert coretlv.session.get_node(node_id, NodeBase) is not None
def test_node_update(self, coretlv):
def test_node_update(self, coretlv: CoreHandler):
node_id = 1
coretlv.session.add_node(CoreNode, _id=node_id)
x = 50
@ -82,7 +86,7 @@ class TestGui:
assert node.position.x == x
assert node.position.y == y
def test_node_delete(self, coretlv):
def test_node_delete(self, coretlv: CoreHandler):
node_id = 1
coretlv.session.add_node(CoreNode, _id=node_id)
message = coreapi.CoreNodeMessage.create(
@ -94,7 +98,7 @@ class TestGui:
with pytest.raises(CoreError):
coretlv.session.get_node(node_id, NodeBase)
def test_link_add_node_to_net(self, coretlv):
def test_link_add_node_to_net(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
switch = 2
@ -118,7 +122,7 @@ class TestGui:
all_links = switch_node.all_link_data()
assert len(all_links) == 1
def test_link_add_net_to_node(self, coretlv):
def test_link_add_net_to_node(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
switch = 2
@ -142,7 +146,7 @@ class TestGui:
all_links = switch_node.all_link_data()
assert len(all_links) == 1
def test_link_add_node_to_node(self, coretlv):
def test_link_add_node_to_node(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
node_two = 2
@ -172,7 +176,7 @@ class TestGui:
all_links += node.all_link_data()
assert len(all_links) == 1
def test_link_update(self, coretlv):
def test_link_update(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
switch = 2
@ -214,7 +218,7 @@ class TestGui:
link = all_links[0]
assert link.bandwidth == bandwidth
def test_link_delete_node_to_node(self, coretlv):
def test_link_delete_node_to_node(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
node_two = 2
@ -258,7 +262,7 @@ class TestGui:
all_links += node.all_link_data()
assert len(all_links) == 0
def test_link_delete_node_to_net(self, coretlv):
def test_link_delete_node_to_net(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
switch = 2
@ -294,7 +298,7 @@ class TestGui:
all_links = switch_node.all_link_data()
assert len(all_links) == 0
def test_link_delete_net_to_node(self, coretlv):
def test_link_delete_net_to_node(self, coretlv: CoreHandler):
node_one = 1
coretlv.session.add_node(CoreNode, _id=node_one)
switch = 2
@ -330,7 +334,7 @@ class TestGui:
all_links = switch_node.all_link_data()
assert len(all_links) == 0
def test_session_update(self, coretlv):
def test_session_update(self, coretlv: CoreHandler):
session_id = coretlv.session.id
name = "test"
message = coreapi.CoreSessionMessage.create(
@ -341,7 +345,7 @@ class TestGui:
assert coretlv.session.name == name
def test_session_query(self, coretlv):
def test_session_query(self, coretlv: CoreHandler):
coretlv.dispatch_replies = mock.MagicMock()
message = coreapi.CoreSessionMessage.create(MessageFlags.STRING.value, [])
@ -351,7 +355,7 @@ class TestGui:
replies = args[0]
assert len(replies) == 1
def test_session_join(self, coretlv):
def test_session_join(self, coretlv: CoreHandler):
coretlv.dispatch_replies = mock.MagicMock()
session_id = coretlv.session.id
message = coreapi.CoreSessionMessage.create(
@ -362,7 +366,7 @@ class TestGui:
assert coretlv.session.id == session_id
def test_session_delete(self, coretlv):
def test_session_delete(self, coretlv: CoreHandler):
assert len(coretlv.coreemu.sessions) == 1
session_id = coretlv.session.id
message = coreapi.CoreSessionMessage.create(
@ -373,7 +377,7 @@ class TestGui:
assert len(coretlv.coreemu.sessions) == 0
def test_file_hook_add(self, coretlv):
def test_file_hook_add(self, coretlv: CoreHandler):
state = EventTypes.DATACOLLECT_STATE
assert coretlv.session._hooks.get(state) is None
file_name = "test.sh"
@ -395,7 +399,7 @@ class TestGui:
assert file_name == name
assert file_data == data
def test_file_service_file_set(self, coretlv):
def test_file_service_file_set(self, coretlv: CoreHandler):
node = coretlv.session.add_node(CoreNode)
service = "DefaultRoute"
file_name = "defaultroute.sh"
@ -417,7 +421,7 @@ class TestGui:
)
assert file_data == service_file.data
def test_file_node_file_copy(self, request, coretlv):
def test_file_node_file_copy(self, request, coretlv: CoreHandler):
file_name = "/var/log/test/node.log"
node = coretlv.session.add_node(CoreNode)
node.makenodedir()
@ -439,7 +443,7 @@ class TestGui:
create_path = os.path.join(node.nodedir, created_directory, basename)
assert os.path.exists(create_path)
def test_exec_node_tty(self, coretlv):
def test_exec_node_tty(self, coretlv: CoreHandler):
coretlv.dispatch_replies = mock.MagicMock()
node = coretlv.session.add_node(CoreNode)
message = coreapi.CoreExecMessage.create(
@ -457,7 +461,7 @@ class TestGui:
replies = args[0]
assert len(replies) == 1
def test_exec_local_command(self, request, coretlv):
def test_exec_local_command(self, request, coretlv: CoreHandler):
if request.config.getoption("mock"):
pytest.skip("mocking calls")
@ -479,7 +483,7 @@ class TestGui:
replies = args[0]
assert len(replies) == 1
def test_exec_node_command(self, coretlv):
def test_exec_node_command(self, coretlv: CoreHandler):
coretlv.dispatch_replies = mock.MagicMock()
node = coretlv.session.add_node(CoreNode)
cmd = "echo hello"
@ -514,7 +518,7 @@ class TestGui:
assert coretlv.session.state == state
def test_event_schedule(self, coretlv):
def test_event_schedule(self, coretlv: CoreHandler):
coretlv.session.add_event = mock.MagicMock()
node = coretlv.session.add_node(CoreNode)
message = coreapi.CoreEventMessage.create(
@ -602,7 +606,7 @@ class TestGui:
coretlv.handle_message(message)
def test_register_gui(self, coretlv):
def test_register_gui(self, coretlv: CoreHandler):
message = coreapi.CoreRegMessage.create(0, [(RegisterTlvs.GUI, "gui")])
coretlv.handle_message(message)
@ -638,7 +642,7 @@ class TestGui:
assert len(coretlv.session.nodes) == 1
def test_config_all(self, coretlv):
def test_config_all(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
MessageFlags.ADD.value,
[(ConfigTlvs.OBJECT, "all"), (ConfigTlvs.TYPE, ConfigFlags.RESET.value)],
@ -649,7 +653,7 @@ class TestGui:
assert coretlv.session.location.refxyz == (0, 0, 0)
def test_config_options_request(self, coretlv):
def test_config_options_request(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -663,7 +667,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_options_update(self, coretlv):
def test_config_options_update(self, coretlv: CoreHandler):
test_key = "test"
test_value = "test"
values = {test_key: test_value}
@ -680,7 +684,7 @@ class TestGui:
assert coretlv.session.options.get_config(test_key) == test_value
def test_config_location_reset(self, coretlv):
def test_config_location_reset(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -694,7 +698,7 @@ class TestGui:
assert coretlv.session.location.refxyz == (0, 0, 0)
def test_config_location_update(self, coretlv):
def test_config_location_update(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -710,7 +714,7 @@ class TestGui:
assert coretlv.session.location.refgeo == (70, 50, 0)
assert coretlv.session.location.refscale == 0.5
def test_config_metadata_request(self, coretlv):
def test_config_metadata_request(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -724,7 +728,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_metadata_update(self, coretlv):
def test_config_metadata_update(self, coretlv: CoreHandler):
test_key = "test"
test_value = "test"
values = {test_key: test_value}
@ -741,7 +745,7 @@ class TestGui:
assert coretlv.session.metadata[test_key] == test_value
def test_config_broker_request(self, coretlv):
def test_config_broker_request(self, coretlv: CoreHandler):
server = "test"
host = "10.0.0.1"
port = 50000
@ -759,7 +763,7 @@ class TestGui:
coretlv.session.distributed.add_server.assert_called_once_with(server, host)
def test_config_services_request_all(self, coretlv):
def test_config_services_request_all(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -773,7 +777,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_services_request_specific(self, coretlv):
def test_config_services_request_specific(self, coretlv: CoreHandler):
node = coretlv.session.add_node(CoreNode)
message = coreapi.CoreConfMessage.create(
0,
@ -790,7 +794,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_services_request_specific_file(self, coretlv):
def test_config_services_request_specific_file(self, coretlv: CoreHandler):
node = coretlv.session.add_node(CoreNode)
message = coreapi.CoreConfMessage.create(
0,
@ -807,7 +811,7 @@ class TestGui:
coretlv.session.broadcast_file.assert_called_once()
def test_config_services_reset(self, coretlv):
def test_config_services_reset(self, coretlv: CoreHandler):
node = coretlv.session.add_node(CoreNode)
service = "DefaultRoute"
coretlv.session.services.set_service(node.id, service)
@ -824,7 +828,7 @@ class TestGui:
assert coretlv.session.services.get_service(node.id, service) is None
def test_config_services_set(self, coretlv):
def test_config_services_set(self, coretlv: CoreHandler):
node = coretlv.session.add_node(CoreNode)
service = "DefaultRoute"
values = {"meta": "metadata"}
@ -844,7 +848,7 @@ class TestGui:
assert coretlv.session.services.get_service(node.id, service) is not None
def test_config_mobility_reset(self, coretlv):
def test_config_mobility_reset(self, coretlv: CoreHandler):
wlan = coretlv.session.add_node(WlanNode)
message = coreapi.CoreConfMessage.create(
0,
@ -860,7 +864,7 @@ class TestGui:
assert len(coretlv.session.mobility.node_configurations) == 0
def test_config_mobility_model_request(self, coretlv):
def test_config_mobility_model_request(self, coretlv: CoreHandler):
wlan = coretlv.session.add_node(WlanNode)
message = coreapi.CoreConfMessage.create(
0,
@ -876,7 +880,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_mobility_model_update(self, coretlv):
def test_config_mobility_model_update(self, coretlv: CoreHandler):
wlan = coretlv.session.add_node(WlanNode)
config_key = "range"
config_value = "1000"
@ -898,7 +902,7 @@ class TestGui:
)
assert config[config_key] == config_value
def test_config_emane_model_request(self, coretlv):
def test_config_emane_model_request(self, coretlv: CoreHandler):
wlan = coretlv.session.add_node(WlanNode)
message = coreapi.CoreConfMessage.create(
0,
@ -914,7 +918,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_emane_model_update(self, coretlv):
def test_config_emane_model_update(self, coretlv: CoreHandler):
wlan = coretlv.session.add_node(WlanNode)
config_key = "distance"
config_value = "50051"
@ -936,7 +940,7 @@ class TestGui:
)
assert config[config_key] == config_value
def test_config_emane_request(self, coretlv):
def test_config_emane_request(self, coretlv: CoreHandler):
message = coreapi.CoreConfMessage.create(
0,
[
@ -950,7 +954,7 @@ class TestGui:
coretlv.handle_broadcast_config.assert_called_once()
def test_config_emane_update(self, coretlv):
def test_config_emane_update(self, coretlv: CoreHandler):
config_key = "eventservicedevice"
config_value = "eth4"
values = {config_key: config_value}

View file

@ -1,9 +1,14 @@
from core.emulator.emudata import LinkOptions
from typing import Tuple
from core.emulator.emudata import IpPrefixes, LinkOptions
from core.emulator.session import Session
from core.nodes.base import CoreNode
from core.nodes.network import SwitchNode
def create_ptp_network(session, ip_prefixes):
def create_ptp_network(
session: Session, ip_prefixes: IpPrefixes
) -> Tuple[CoreNode, CoreNode]:
# create nodes
node_one = session.add_node(CoreNode)
node_two = session.add_node(CoreNode)
@ -20,7 +25,7 @@ def create_ptp_network(session, ip_prefixes):
class TestLinks:
def test_ptp(self, session, ip_prefixes):
def test_ptp(self, session: Session, ip_prefixes: IpPrefixes):
# given
node_one = session.add_node(CoreNode)
node_two = session.add_node(CoreNode)
@ -34,7 +39,7 @@ class TestLinks:
assert node_one.netif(interface_one.id)
assert node_two.netif(interface_two.id)
def test_node_to_net(self, session, ip_prefixes):
def test_node_to_net(self, session: Session, ip_prefixes: IpPrefixes):
# given
node_one = session.add_node(CoreNode)
node_two = session.add_node(SwitchNode)
@ -47,7 +52,7 @@ class TestLinks:
assert node_two.all_link_data()
assert node_one.netif(interface_one.id)
def test_net_to_node(self, session, ip_prefixes):
def test_net_to_node(self, session: Session, ip_prefixes: IpPrefixes):
# given
node_one = session.add_node(SwitchNode)
node_two = session.add_node(CoreNode)
@ -71,7 +76,7 @@ class TestLinks:
# then
assert node_one.all_link_data()
def test_link_update(self, session, ip_prefixes):
def test_link_update(self, session: Session, ip_prefixes: IpPrefixes):
# given
delay = 50
bandwidth = 5000000
@ -110,7 +115,7 @@ class TestLinks:
assert interface_one.getparam("duplicate") == dup
assert interface_one.getparam("jitter") == jitter
def test_link_delete(self, session, ip_prefixes):
def test_link_delete(self, session: Session, ip_prefixes: IpPrefixes):
# given
node_one = session.add_node(CoreNode)
node_two = session.add_node(CoreNode)

View file

@ -1,6 +1,7 @@
import pytest
from core.emulator.emudata import NodeOptions
from core.emulator.session import Session
from core.errors import CoreError
from core.nodes.base import CoreNode
from core.nodes.network import HubNode, SwitchNode, WlanNode
@ -11,7 +12,7 @@ NET_TYPES = [SwitchNode, HubNode, WlanNode]
class TestNodes:
@pytest.mark.parametrize("model", MODELS)
def test_node_add(self, session, model):
def test_node_add(self, session: Session, model: str):
# given
options = NodeOptions(model=model)
@ -23,7 +24,7 @@ class TestNodes:
assert node.alive()
assert node.up
def test_node_update(self, session):
def test_node_update(self, session: Session):
# given
node = session.add_node(CoreNode)
position_value = 100
@ -37,7 +38,7 @@ class TestNodes:
assert node.position.x == position_value
assert node.position.y == position_value
def test_node_delete(self, session):
def test_node_delete(self, session: Session):
# given
node = session.add_node(CoreNode)
@ -48,7 +49,7 @@ class TestNodes:
with pytest.raises(CoreError):
session.get_node(node.id, CoreNode)
def test_node_sethwaddr(self, session):
def test_node_sethwaddr(self, session: Session):
# given
node = session.add_node(CoreNode)
index = node.newnetif()
@ -61,7 +62,7 @@ class TestNodes:
# then
assert interface.hwaddr == mac
def test_node_sethwaddr_exception(self, session):
def test_node_sethwaddr_exception(self, session: Session):
# given
node = session.add_node(CoreNode)
index = node.newnetif()
@ -72,7 +73,7 @@ class TestNodes:
with pytest.raises(CoreError):
node.sethwaddr(index, mac)
def test_node_addaddr(self, session):
def test_node_addaddr(self, session: Session):
# given
node = session.add_node(CoreNode)
index = node.newnetif()

View file

@ -3,6 +3,7 @@ import os
import pytest
from mock import MagicMock
from core.emulator.session import Session
from core.errors import CoreCommandError
from core.nodes.base import CoreNode
from core.services.coreservices import CoreService, ServiceDependencies, ServiceManager
@ -49,7 +50,7 @@ class ServiceCycleDependency(CoreService):
class TestServices:
def test_service_all_files(self, session):
def test_service_all_files(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
file_name = "myservice.sh"
@ -64,7 +65,7 @@ class TestServices:
assert service
assert all_files and len(all_files) == 1
def test_service_all_configs(self, session):
def test_service_all_configs(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
node = session.add_node(CoreNode)
@ -78,7 +79,7 @@ class TestServices:
assert all_configs
assert len(all_configs) == 2
def test_service_add_services(self, session):
def test_service_add_services(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
node = session.add_node(CoreNode)
@ -91,7 +92,7 @@ class TestServices:
assert node.services
assert len(node.services) == total_service + 2
def test_service_file(self, request, session):
def test_service_file(self, request, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -106,7 +107,7 @@ class TestServices:
if not request.config.getoption("mock"):
assert os.path.exists(file_path)
def test_service_validate(self, session):
def test_service_validate(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -119,7 +120,7 @@ class TestServices:
# then
assert not status
def test_service_validate_error(self, session):
def test_service_validate_error(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_TWO)
@ -133,7 +134,7 @@ class TestServices:
# then
assert status
def test_service_startup(self, session):
def test_service_startup(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -146,7 +147,7 @@ class TestServices:
# then
assert not status
def test_service_startup_error(self, session):
def test_service_startup_error(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_TWO)
@ -160,7 +161,7 @@ class TestServices:
# then
assert status
def test_service_stop(self, session):
def test_service_stop(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -173,7 +174,7 @@ class TestServices:
# then
assert not status
def test_service_stop_error(self, session):
def test_service_stop_error(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_TWO)
@ -187,7 +188,7 @@ class TestServices:
# then
assert status
def test_service_custom_startup(self, session):
def test_service_custom_startup(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -201,7 +202,7 @@ class TestServices:
# then
assert my_service.startup != custom_my_service.startup
def test_service_set_file(self, session):
def test_service_set_file(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)
@ -231,7 +232,7 @@ class TestServices:
assert ServiceManager.get(SERVICE_ONE)
assert ServiceManager.get(SERVICE_TWO)
def test_service_setget(self, session):
def test_service_setget(self, session: Session):
# given
ServiceManager.add_services(_SERVICES_PATH)
my_service = ServiceManager.get(SERVICE_ONE)

View file

@ -34,12 +34,12 @@ class TestUtils:
("2001::/64", "2001::/64"),
],
)
def test_validate_ip(self, data, expected):
def test_validate_ip(self, data: str, expected: str):
value = utils.validate_ip(data)
assert value == expected
@pytest.mark.parametrize("data", ["256", "1270.0.0.1", "127.0.0.0.1"])
def test_validate_ip_exception(self, data):
def test_validate_ip_exception(self, data: str):
with pytest.raises(CoreError):
utils.validate_ip("")
@ -50,14 +50,14 @@ class TestUtils:
("00:00:00:FF:FF:FF", "00:00:00:ff:ff:ff"),
],
)
def test_validate_mac(self, data, expected):
def test_validate_mac(self, data: str, expected: str):
value = utils.validate_mac(data)
assert value == expected
@pytest.mark.parametrize(
"data", ["AAA:AA:AA:FF:FF:FF", "AA:AA:AA:FF:FF", "AA/AA/AA/FF/FF/FF"]
)
def test_validate_mac_exception(self, data):
def test_validate_mac_exception(self, data: str):
with pytest.raises(CoreError):
utils.validate_mac(data)

View file

@ -1,9 +1,11 @@
from tempfile import TemporaryFile
from xml.etree import ElementTree
import pytest
from core.emulator.emudata import LinkOptions, NodeOptions
from core.emulator.emudata import IpPrefixes, LinkOptions, NodeOptions
from core.emulator.enumerations import EventTypes
from core.emulator.session import Session
from core.errors import CoreError
from core.location.mobility import BasicRangeModel
from core.nodes.base import CoreNode
@ -12,7 +14,7 @@ from core.services.utility import SshService
class TestXml:
def test_xml_hooks(self, session, tmpdir):
def test_xml_hooks(self, session: Session, tmpdir: TemporaryFile):
"""
Test save/load hooks in xml.
@ -52,7 +54,9 @@ class TestXml:
assert file_name == runtime_hook[0]
assert data == runtime_hook[1]
def test_xml_ptp(self, session, tmpdir, ip_prefixes):
def test_xml_ptp(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for a ptp network.
@ -104,7 +108,9 @@ class TestXml:
assert session.get_node(n1_id, CoreNode)
assert session.get_node(n2_id, CoreNode)
def test_xml_ptp_services(self, session, tmpdir, ip_prefixes):
def test_xml_ptp_services(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for a ptp neetwork.
@ -169,7 +175,9 @@ class TestXml:
assert session.get_node(n2_id, CoreNode)
assert service.config_data.get(service_file) == file_data
def test_xml_mobility(self, session, tmpdir, ip_prefixes):
def test_xml_mobility(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for mobility.
@ -230,7 +238,7 @@ class TestXml:
assert session.get_node(wlan_id, WlanNode)
assert value == "1"
def test_network_to_network(self, session, tmpdir):
def test_network_to_network(self, session: Session, tmpdir: TemporaryFile):
"""
Test xml generation when dealing with network to network nodes.
@ -279,7 +287,9 @@ class TestXml:
assert switch_two
assert len(switch_one.all_link_data() + switch_two.all_link_data()) == 1
def test_link_options(self, session, tmpdir, ip_prefixes):
def test_link_options(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for a ptp network.
@ -345,7 +355,9 @@ class TestXml:
assert link_options.delay == link.delay
assert link_options.dup == link.dup
def test_link_options_ptp(self, session, tmpdir, ip_prefixes):
def test_link_options_ptp(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for a ptp network.
@ -412,7 +424,9 @@ class TestXml:
assert link_options.delay == link.delay
assert link_options.dup == link.dup
def test_link_options_bidirectional(self, session, tmpdir, ip_prefixes):
def test_link_options_bidirectional(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
):
"""
Test xml client methods for a ptp network.