update tests and make office lan creation work like previously
This commit is contained in:
@@ -155,7 +155,12 @@ class OfficeLANAdder(NetworkNodeAdder, discriminator="office-lan"):
|
|||||||
# Create a core switch if more than one edge switch is needed
|
# Create a core switch if more than one edge switch is needed
|
||||||
if num_of_switches > 1:
|
if num_of_switches > 1:
|
||||||
core_switch = Switch.from_config(
|
core_switch = Switch.from_config(
|
||||||
config={"type": "switch", "hostname": f"switch_core_{config.lan_name}", "start_up_duration": 0}
|
config={
|
||||||
|
"type": "switch",
|
||||||
|
"hostname": f"switch_core_{config.lan_name}",
|
||||||
|
"start_up_duration": 0,
|
||||||
|
"num_ports": 24,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
core_switch.power_on()
|
core_switch.power_on()
|
||||||
network.add_node(core_switch)
|
network.add_node(core_switch)
|
||||||
@@ -183,7 +188,12 @@ class OfficeLANAdder(NetworkNodeAdder, discriminator="office-lan"):
|
|||||||
switch_port = 0
|
switch_port = 0
|
||||||
switch_n = 1
|
switch_n = 1
|
||||||
switch = Switch.from_config(
|
switch = Switch.from_config(
|
||||||
config={"type": "switch", "hostname": f"switch_edge_{switch_n}_{config.lan_name}", "start_up_duration": 0}
|
config={
|
||||||
|
"type": "switch",
|
||||||
|
"hostname": f"switch_edge_{switch_n}_{config.lan_name}",
|
||||||
|
"start_up_duration": 0,
|
||||||
|
"num_ports": 24,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
switch.power_on()
|
switch.power_on()
|
||||||
network.add_node(switch)
|
network.add_node(switch)
|
||||||
@@ -207,6 +217,7 @@ class OfficeLANAdder(NetworkNodeAdder, discriminator="office-lan"):
|
|||||||
"type": "switch",
|
"type": "switch",
|
||||||
"hostname": f"switch_edge_{switch_n}_{config.lan_name}",
|
"hostname": f"switch_edge_{switch_n}_{config.lan_name}",
|
||||||
"start_up_duration": 0,
|
"start_up_duration": 0,
|
||||||
|
"num_ports": 24,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
switch.power_on()
|
switch.power_on()
|
||||||
|
|||||||
@@ -17,4 +17,3 @@ def switch() -> Switch:
|
|||||||
def test_describe_state(switch):
|
def test_describe_state(switch):
|
||||||
state = switch.describe_state()
|
state = switch.describe_state()
|
||||||
assert len(state.get("ports")) is 8
|
assert len(state.get("ports")) is 8
|
||||||
assert state.get("num_ports") is 8
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_scan(application):
|
|||||||
|
|
||||||
def test_run_application(application):
|
def test_run_application(application):
|
||||||
assert application.operating_state == ApplicationOperatingState.CLOSED
|
assert application.operating_state == ApplicationOperatingState.CLOSED
|
||||||
assert application.health_state_actual == SoftwareHealthState.UNUSED
|
assert application.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
application.run()
|
application.run()
|
||||||
assert application.operating_state == ApplicationOperatingState.RUNNING
|
assert application.operating_state == ApplicationOperatingState.RUNNING
|
||||||
@@ -37,9 +37,9 @@ def test_close_application(application):
|
|||||||
|
|
||||||
def test_application_describe_states(application):
|
def test_application_describe_states(application):
|
||||||
assert application.operating_state == ApplicationOperatingState.CLOSED
|
assert application.operating_state == ApplicationOperatingState.CLOSED
|
||||||
assert application.health_state_actual == SoftwareHealthState.UNUSED
|
assert application.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
assert SoftwareHealthState.UNUSED.value == application.describe_state().get("health_state_actual")
|
assert SoftwareHealthState.GOOD.value == application.describe_state().get("health_state_actual")
|
||||||
|
|
||||||
application.run()
|
application.run()
|
||||||
assert SoftwareHealthState.GOOD.value == application.describe_state().get("health_state_actual")
|
assert SoftwareHealthState.GOOD.value == application.describe_state().get("health_state_actual")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def test_scan(service):
|
|||||||
|
|
||||||
def test_start_service(service):
|
def test_start_service(service):
|
||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
service.start()
|
service.start()
|
||||||
|
|
||||||
assert service.operating_state == ServiceOperatingState.RUNNING
|
assert service.operating_state == ServiceOperatingState.RUNNING
|
||||||
@@ -43,7 +43,7 @@ def test_pause_and_resume_service(service):
|
|||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
service.resume()
|
service.resume()
|
||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
service.start()
|
service.start()
|
||||||
assert service.health_state_actual == SoftwareHealthState.GOOD
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
@@ -58,11 +58,11 @@ def test_pause_and_resume_service(service):
|
|||||||
|
|
||||||
def test_restart(service):
|
def test_restart(service):
|
||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
service.restart()
|
service.restart()
|
||||||
# Service is STOPPED. Restart will only work if the service was PAUSED or RUNNING
|
# Service is STOPPED. Restart will only work if the service was PAUSED or RUNNING
|
||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
service.start()
|
service.start()
|
||||||
assert service.operating_state == ServiceOperatingState.RUNNING
|
assert service.operating_state == ServiceOperatingState.RUNNING
|
||||||
@@ -157,11 +157,11 @@ def test_service_fixing(service):
|
|||||||
def test_enable_disable(service):
|
def test_enable_disable(service):
|
||||||
service.disable()
|
service.disable()
|
||||||
assert service.operating_state == ServiceOperatingState.DISABLED
|
assert service.operating_state == ServiceOperatingState.DISABLED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
service.enable()
|
service.enable()
|
||||||
assert service.operating_state == ServiceOperatingState.STOPPED
|
assert service.operating_state == ServiceOperatingState.STOPPED
|
||||||
assert service.health_state_actual == SoftwareHealthState.UNUSED
|
assert service.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
|
||||||
|
|
||||||
def test_overwhelm_service(service):
|
def test_overwhelm_service(service):
|
||||||
|
|||||||
@@ -39,6 +39,6 @@ def test_software_creation(software):
|
|||||||
|
|
||||||
|
|
||||||
def test_software_set_health_state(software):
|
def test_software_set_health_state(software):
|
||||||
assert software.health_state_actual == SoftwareHealthState.UNUSED
|
|
||||||
software.set_health_state(SoftwareHealthState.GOOD)
|
|
||||||
assert software.health_state_actual == SoftwareHealthState.GOOD
|
assert software.health_state_actual == SoftwareHealthState.GOOD
|
||||||
|
software.set_health_state(SoftwareHealthState.COMPROMISED)
|
||||||
|
assert software.health_state_actual == SoftwareHealthState.COMPROMISED
|
||||||
|
|||||||
Reference in New Issue
Block a user