def test_sensorAllGo(self): controller = TrafficLightController("MOCK") tl = controller.getTL() tl.switchOff() tl.greenOn() tl.tgreenOn() car1 = Car("Car1", "EAST", "STRAIGHT") car2 = Car("Car2", "EAST", "RIGHT") car3 = Car("Car3", "EAST", "LEFT") lane = [car1, car2, car3, car3] simulator.sensor(controller, lane) self.assertEqual(lane, [car2, car3, car3])
def test_sensorStraightOrange(self): """ Test straight orange lights """ controller = TrafficLightController("MOCK") tl = controller.getTL() tl.switchOff() tl.tredOn() tl.orangeOn() car1 = Car("Car1", "EAST", "STRAIGHT") car2 = Car("Car2", "EAST", "RIGHT") car3 = Car("Car3", "EAST", "LEFT") lane = [car1, car2, car3, car3] simulator.sensor(controller, lane) self.assertEqual(lane, [car2, car3])
def test_lightsBrokenLogic(self): """ Tests lightsAreBroken works as intended """ simulator.lightsAreBroken = True controller = TrafficLightController("TEST") tl = controller.getTL() tl.switchOff() tl.greenOn() tl.tgreenOn() car1 = Car("Car1", "EAST", "STRAIGHT") car2 = Car("Car2", "EAST", "RIGHT") car3 = Car("Car3", "EAST", "LEFT") lane = [car1, car2, car3, car3] simulator.sensor(controller, lane) self.assertEqual(lane, [car1, car2, car3, car3]) # Reset the variable so as not to break anything simulator.lightsAreBroken = False