Rename networkcontainer to network

This commit is contained in:
Marek Wolan
2023-08-24 12:41:46 +01:00
parent a818de8f01
commit 7058c7e9a8
4 changed files with 13 additions and 13 deletions

View File

@@ -1,12 +1,12 @@
import pytest
from primaite.simulator.network.container import NetworkContainer
from primaite.simulator.network.container import Network
from primaite.simulator.network.hardware.base import NIC, Node
def test_adding_removing_nodes():
"""Check that we can create and add a node to a network."""
net = NetworkContainer()
net = Network()
n1 = Node(hostname="computer")
net.add_node(n1)
assert n1.parent is net
@@ -19,7 +19,7 @@ def test_adding_removing_nodes():
def test_readding_node():
"""Check that warning is raised when readding a node."""
net = NetworkContainer()
net = Network()
n1 = Node(hostname="computer")
net.add_node(n1)
with pytest.raises(RuntimeWarning):
@@ -30,7 +30,7 @@ def test_readding_node():
def test_removing_nonexistent_node():
"""Check that warning is raised when trying to remove a node that is not in the network."""
net = NetworkContainer()
net = Network()
n1 = Node(hostname="computer")
with pytest.raises(RuntimeWarning):
net.remove_node(n1)
@@ -40,7 +40,7 @@ def test_removing_nonexistent_node():
def test_connecting_nodes():
"""Check that two nodes on the network can be connected."""
net = NetworkContainer()
net = Network()
n1 = Node(hostname="computer")
n1_nic = NIC(ip_address="120.30.0.1", gateway="192.168.0.1", subnet_mask="255.255.255.0")
n1.connect_nic(n1_nic)
@@ -60,7 +60,7 @@ def test_connecting_nodes():
def test_connecting_node_to_itself():
net = NetworkContainer()
net = Network()
node = Node(hostname="computer")
nic1 = NIC(ip_address="120.30.0.1", gateway="192.168.0.1", subnet_mask="255.255.255.0")
node.connect_nic(nic1)

View File

@@ -1,16 +1,16 @@
import json
from primaite.simulator.network.container import NetworkContainer
from primaite.simulator.network.container import Network
def test_creating_container():
"""Check that we can create a network container"""
net = NetworkContainer()
net = Network()
assert net.nodes and net.links
def test_describe_state():
"""Check that we can describe network state without raising errors, and that the result is JSON serialisable."""
net = NetworkContainer()
net = Network()
state = net.describe_state()
json.dumps(state) # if this function call raises an error, the test fails, state was not JSON-serialisable