def _create_test_ship(): return Ship( **{ directions.YAW: 0, directions.ROLL: 0, directions.PITCH: 0, "reactors": [Reactor(max_output=20)], "reaction_wheels": [ ReactionWheel( axis=axis, rotation=directions.FORWARD, max_force=15) for axis in [directions.YAW, directions.ROLL, directions.PITCH] ], **{ F"{direction}_panel": ShipPanel(side=directions.COUNTER_DIRECTIONS[direction], thrusters=[ Thruster(max_force=10.0) ], sensors=[ Sensor(base_range=2000) ]) for direction in directions.DIRECTIONS } })
def _get_sensors_for_assertion(ship_orientation={}, sensor_orientation={}, scan_direction=None, sensor_focus=89, has_power=True): reactor = Reactor(max_output=200) panels = { F"{direction}_panel": ShipPanel(side=direction, sensors=[ Sensor(base_range=2000, focus=sensor_focus, pitch=sensor_orientation.get(PITCH, 90), yaw=sensor_orientation.get(YAW, 90)) ]) for direction in DIRECTIONS } ship = Ship( **{ **panels, "reactors": [reactor] if has_power else [], PITCH: ship_orientation.get(PITCH, 0), ROLL: ship_orientation.get(ROLL, 0), YAW: ship_orientation.get(YAW, 0), }) if scan_direction is None: sensors = [ sensor for panel in ship.panels.values() for sensor in panel.sensors ] else: sensors = [sensor for sensor in ship.panels[scan_direction].sensors] return sensors
def _create_test_ship(): return Ship( **{ "reactors": [Reactor(max_output=2000)], "reaction_wheels": [ ReactionWheel( axis=axis, rotation=directions.CLOCKWISE, max_force=750) for axis in [directions.YAW, directions.ROLL, directions.PITCH] ] + [ ReactionWheel(axis=axis, rotation=directions.COUNTER_CLOCKWISE, max_force=750) for axis in [directions.YAW, directions.ROLL, directions.PITCH] ], **{ F"{direction}_panel": ShipPanel( side=directions.COUNTER_DIRECTIONS[direction], thrusters=[Thruster(max_force=50.0)], sensors=[Sensor(base_range=1500.0, focus=90)], ) for direction in directions.DIRECTIONS } })
def test_pitch_degrees_status_report_neg(): r = Sensor(base_range=100, focus=10, pitch=90, yaw=90) assert r.status_report["pitch_degrees"] == r.pitch_degrees, \ "Sensor pitch_degrees is innacurately reported"
def test_current_range_status_report_long(): r = Sensor(base_range=20000, focus=180, pitch=90, yaw=90) assert r.status_report["current_range"] == r.range, \ "Sensor range is innacurately reported"
def test_lor_integrity_status_report(): reactor = Sensor(base_range=2000, focus=90, pitch=90, yaw=90) reactor.degrade(0.5) assert reactor.status_report["integrity"] == reactor.integrity, \ "Sensor integrity is innacurately reported"
def test_base_range_status_report(): r = Sensor(base_range=2000, focus=10, pitch=90, yaw=90) assert r.status_report["base_range"] == r.base_range, \ "Sensor base_range is innacurately reported"
def test_focus_status_report_wide(): r = Sensor(base_range=2000, focus=180, pitch=90, yaw=90) assert r.status_report["focus"] == r.focus, \ "Sensor focus is innacurately reported"
def test_powered_on_status_report(): reactor = Sensor(base_range=2000, focus=90, pitch=90, yaw=90) reactor.powered_on = False assert reactor.status_report["powered_on"] == reactor.powered_on, \ "Sensor powered_on is innacurately reported"
def test_is_active_status_report_no_power(): reactor = Sensor(base_range=2000, focus=90, pitch=90, yaw=90) reactor.powered_on = False assert reactor.status_report["is_active"] == reactor.is_active, \ "Sensor is_active is innacurately reported"
def test_is_active_status_report_no_integrity(): reactor = Sensor(base_range=2000, focus=90, pitch=90, yaw=90) reactor.degrade(1) assert reactor.status_report["is_active"] == reactor.is_active, \ "Sensor is_active is innacurately reported"
def test_yaw_degrees_status_report(): r = Sensor(base_range=100, focus=10, pitch=-90, yaw=90) assert r.status_report["yaw_degrees"] == r.yaw_degrees, \ "Sensor yaw_degrees is innacurately reported"