Skip to content

Commit

Permalink
add device discovery task
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelSuleiman committed Nov 30, 2023
2 parents 58f53a2 + 6c2afe1 commit e815253
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions uniconfig/python/tests/test_device_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from frinx_api.uniconfig.device.discovery.discover import TcpPortItem
from frinx_api.uniconfig.device.discovery.discover import UdpPortItem

# from frinx_worker.uniconfig.device_discovery import DeviceDiscoveryWorkers
from uniconfig.python.frinx_worker.uniconfig.device_discovery import DeviceDiscoveryWorkers # type: ignore
from frinx_worker.uniconfig.device_discovery import DeviceDiscoveryWorkers

# from uniconfig.python.frinx_worker.uniconfig.device_discovery import DeviceDiscoveryWorkers # type: ignore


class TestDeviceDiscovery(unittest.TestCase):
Expand All @@ -14,47 +15,47 @@ def test_tcp_validation_list(self) -> None:
tcp_port = '21,22,23'
expected = [TcpPortItem(port=21), TcpPortItem(port=22), TcpPortItem(port=23)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port))
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

def test_tcp_validation_range(self) -> None:
tcp_port = '21-23'
expected = [TcpPortItem(port=21), TcpPortItem(port=22), TcpPortItem(port=23)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port))
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

def test_tcp_validation_list_range(self) -> None:
tcp_port = '21-23,25'
expected = [TcpPortItem(port=21), TcpPortItem(port=22), TcpPortItem(port=23), TcpPortItem(port=25)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port))
DeviceDiscoveryWorker.WorkerInput.validate_tcp(tcp_port=tcp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

def test_udp_validation_list(self) -> None:
udp_port = '21,22,23'
expected = [UdpPortItem(port=21), UdpPortItem(port=22), UdpPortItem(port=23)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port))
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

def test_udp_validation_range(self) -> None:
udp_port = '21-23'
expected = [UdpPortItem(port=21), UdpPortItem(port=22), UdpPortItem(port=23)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port))
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

def test_udp_validation_list_range(self) -> None:
udp_port = '21-23,25'
expected = [UdpPortItem(port=21), UdpPortItem(port=22), UdpPortItem(port=23), UdpPortItem(port=25)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port))
DeviceDiscoveryWorker.WorkerInput.validate_udp(udp_port=udp_port)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -63,7 +64,7 @@ def test_validate_ip_single_ip_v4(self) -> None:
expected = [Address(end_ipv6_address=None, ip_address='192.168.0.59', hostname=None, end_ipv4_address=None,
start_ipv4_address=None, start_ipv6_address=None, network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -73,7 +74,7 @@ def test_validate_ip_range_ip_v4(self) -> None:
end_ipv6_address=None, ip_address=None, hostname=None, end_ipv4_address='192.168.0.90',
start_ipv4_address='192.168.0.59', start_ipv6_address=None, network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -83,7 +84,7 @@ def test_validate_ip_network_v4(self) -> None:
end_ipv6_address=None, ip_address=None, hostname=None, end_ipv4_address=None, start_ipv4_address=None,
start_ipv6_address=None, network='192.168.0.0/24')]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -92,15 +93,15 @@ def test_validate_ip_single_ip_v6(self) -> None:
expected = [Address(end_ipv6_address=None, ip_address='::ffff:c0a8:3b', hostname=None, end_ipv4_address=None,
start_ipv4_address=None, start_ipv6_address=None, network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

ip = '::ffff:c0a8:3b'
expected = [Address(end_ipv6_address=None, ip_address='::ffff:c0a8:3b', hostname=None, end_ipv4_address=None,
start_ipv4_address=None, start_ipv6_address=None, network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -110,7 +111,7 @@ def test_validate_ip_range_ip_v6(self) -> None:
end_ipv6_address='::ffff:c0a8:5a', ip_address=None, hostname=None, end_ipv4_address=None,
start_ipv4_address=None, start_ipv6_address='::ffff:c0a8:3b', network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -119,7 +120,7 @@ def test_validate_ip_range_ip_v6(self) -> None:
end_ipv6_address='::ffff:c0a8:5a', ip_address=None, hostname=None, end_ipv4_address=None,
start_ipv4_address=None, start_ipv6_address='::ffff:c0a8:3b', network=None)]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand All @@ -129,7 +130,7 @@ def test_validate_ip_network_v6(self) -> None:
end_ipv6_address=None, ip_address=None, hostname=None, end_ipv4_address=None, start_ipv4_address=None,
start_ipv6_address=None, network='::ffff:c0a8:0/128')]
result = (DeviceDiscoveryWorkers.
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip))
DeviceDiscoveryWorker.WorkerInput.validate_ip(ip=ip)) # type: ignore
assert expected == result
assert isinstance(result, list)

Expand Down

0 comments on commit e815253

Please sign in to comment.