Files
Bubberstation/code/modules/unit_tests/cable_powernets.dm
SkyratBot b61a3f981d [MIRROR] Unit tests powernets to make sure the whole station is connected. [MDB IGNORE] (#16503)
* Unit tests powernets to make sure the whole station is connected. (#70090)

* Unit tests powernets to make sure the whole station is connected.

* fixes cable tests for blueshift and raptor

* single cable misplacement

* hard map reset

* hec

* tramstation armory stray cable

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Paxilmaniac <paxilmaniac@gmail.com>
Co-authored-by: Tastyfish <crazychris32@gmail.com>
2022-09-29 01:24:37 -04:00

36 lines
1.8 KiB
Plaintext

///Checking all powernets to see if they are properly connected and powered.
/datum/unit_test/cable_powernets
/datum/unit_test/cable_powernets/Run()
for(var/datum/powernet/powernets as anything in SSmachines.powernets)
//nodes (machines, which includes APCs and SMES)
if(!length(powernets.nodes))
TEST_ASSERT(length(powernets.cables), "[powernets] found with no nodes OR cables connected, something has gone horribly wrong.")
var/obj/structure/cable/found_cable = powernets.cables[1]
//Check if they're a station area
var/area/cable_area = get_area(found_cable)
if(!(cable_area.type in GLOB.the_station_areas) || !cable_area.requires_power)
continue
TEST_FAIL("[powernets] found with no nodes connected ([found_cable.x], [found_cable.y], [found_cable.z])).")
//cables
if(!length(powernets.cables))
TEST_ASSERT(length(powernets.nodes), "[powernets] found with no cables OR nodes connected, something has gone horribly wrong.")
var/obj/machinery/power/found_machine = powernets.nodes[1]
//Check if they're a station area
var/area/machine_area = get_area(found_machine)
if(!(machine_area.type in GLOB.the_station_areas) || !machine_area.requires_power)
continue
TEST_FAIL("[powernets] found with no cables connected ([found_machine.x], [found_machine.y], [found_machine.z]).")
if(!powernets.avail && !(locate(/obj/machinery/power/terminal) in powernets.nodes)) //No power roundstart, so check for an SMES connection (Solars, Turbine).
var/obj/structure/cable/random_cable = powernets.cables[1]
//Check if they're a station area
var/area/cable_area = get_area(random_cable)
if(!(cable_area.type in GLOB.the_station_areas) || !cable_area.requires_power)
continue
TEST_FAIL("[powernets] found with no power roundstart, connected to a cable at ([random_cable.x], [random_cable.y], [random_cable.z]).")