Ejemplo n.º 1
0
 def testReturningToBase_ScanningTime(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + SCANNING_TIME is invalid"):
         sm.handle_event(Event.SCANNING_TIME)
Ejemplo n.º 2
0
 def testReturningToBase_FullyCharged(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + FULLY_CHARGED is invalid"):
         sm.handle_event(Event.FULLY_CHARGED)
Ejemplo n.º 3
0
 def testReturningToBase_ArrivedAtBase(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     self.assertEqual(
         sm.get_state(), State.CHARGING,
         "RETURNING_TO_BASE + ARRIVED_AT_BASE -> CHARGING is valid")
Ejemplo n.º 4
0
 def testReturningToBase_LowBattery(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + LOW_BATTERY is invalid"):
         sm.handle_event(Event.LOW_BATTERY)
Ejemplo n.º 5
0
 def testReturningToBase_ArrivedAtMolehill(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + LOW_BATTERY is invalid"):
         sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
Ejemplo n.º 6
0
 def testReturningToBase_StartPatrol(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + START_PATROL is invalid"):
         sm.handle_event(Event.START_PATROL)
Ejemplo n.º 7
0
 def testReturningToBase_DonePatrolling(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + DONE_PATROLLING is invalid"):
         sm.handle_event(Event.DONE_PATROLLING)
Ejemplo n.º 8
0
 def testPatrolling_ArrivedAtMolehill(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
     self.assertEqual(
         sm.get_state(), State.SCARING,
         "PATROLLING + ARRIVED_AT_MOLEHILL -> SCARING is valid")
Ejemplo n.º 9
0
 def testPatrolling_LowBattery(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.LOW_BATTERY)
     self.assertEqual(
         sm.get_state(), State.RETURNING_TO_BASE,
         "PATROLLING + LOW_BATTERY -> RETURNING_TO_BASE is valid")
Ejemplo n.º 10
0
 def testPatrolling_ArrivedAtBase(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     with self.assertRaises(
             InvalidEventException,
             msg="PATROLLING + ARRIVED_AT_BASE is not valid"):
         sm.handle_event(Event.ARRIVED_AT_BASE)
Ejemplo n.º 11
0
 def testScanning_DoneScanning(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     sm.handle_event(Event.DONE_SCANNING)
     self.assertEqual(sm.get_state(), State.PATROLLING,
                      "SCANNING + DONE_SCANNING is invalid")
Ejemplo n.º 12
0
 def testScanning_LowBattery(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     sm.handle_event(Event.LOW_BATTERY)
     self.assertEqual(sm.get_state(), State.PATROLLING,
                      "SCANNING + LOW_BATTERY PATROLLING is valid")
Ejemplo n.º 13
0
 def testScaring_DoneScaring(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
     sm.handle_event(Event.DONE_SCARING)
     self.assertEqual(sm.get_state(), State.PATROLLING,
                      "SCARING + DONE_SCARING -> PATROLLING is valid")
Ejemplo n.º 14
0
 def testScanning_ArrivedAtBase(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     with self.assertRaises(InvalidEventException,
                            msg="SCANNING + ARRIVED_AT_BASE is invalid"):
         sm.handle_event(Event.ARRIVED_AT_BASE)
Ejemplo n.º 15
0
 def testCharging_StartPatrol(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     with self.assertRaises(InvalidEventException,
                            msg="CHARGING + START_PATROL is invalid"):
         sm.handle_event(Event.START_PATROL)
Ejemplo n.º 16
0
 def testScanning_ScanningTime(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     with self.assertRaises(InvalidEventException,
                            msg="SCANNING + SCANNING_TIME is invalid"):
         sm.handle_event(Event.SCANNING_TIME)
Ejemplo n.º 17
0
 def testScanning_FullyCharged(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     with self.assertRaises(InvalidEventException,
                            msg="SCANNING + FULLY_CHARGED is invalid"):
         sm.handle_event(Event.FULLY_CHARGED)
Ejemplo n.º 18
0
 def testScaring_ArrivedAtMolehill(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
     with self.assertRaises(InvalidEventException,
                            msg="SCARING + is invalid"):
         sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
Ejemplo n.º 19
0
 def testCharging_FullyCharged(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     sm.handle_event(Event.FULLY_CHARGED)
     self.assertEqual(sm.get_state(), State.IDLE,
                      "RETURNING_TO_BASE + FULLY_CHARGED -> IDLE is valid")
Ejemplo n.º 20
0
 def testScanning_DoneScaring(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.SCANNING_TIME)
     with self.assertRaises(InvalidEventException,
                            msg="SCANNING + DONE_SCARING is invalid"):
         sm.handle_event(Event.DONE_SCARING)
Ejemplo n.º 21
0
 def testScaring_FullyCharged(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
     with self.assertRaises(InvalidEventException,
                            msg="SCARING + FULLY_CHARGED is invalid"):
         sm.handle_event(Event.FULLY_CHARGED)
Ejemplo n.º 22
0
 def testScaring_LowBattery(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     sm.handle_event(Event.ARRIVED_AT_MOLEHILL)
     sm.handle_event(Event.LOW_BATTERY)
     self.assertEqual(sm.get_state(), State.PATROLLING,
                      "SCARING + LOW_BATTERY -> PATROLLING is valid")
Ejemplo n.º 23
0
 def testCharging_DonePatrolling(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + DONE_PATROLLING is invalid"):
         sm.handle_event(Event.DONE_PATROLLING)
Ejemplo n.º 24
0
 def testCharging_ArrivedAtBase(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + ARRIVED_AT_BASE is invalid"):
         sm.handle_event(Event.ARRIVED_AT_BASE)
Ejemplo n.º 25
0
 def testCharging_ScanningTime(self):
     sm = StateMachine()
     sm.handle_event(Event.LOW_BATTERY)
     sm.handle_event(Event.ARRIVED_AT_BASE)
     with self.assertRaises(
             InvalidEventException,
             msg="RETURNING_TO_BASE + SCANNING_TIME is invalid"):
         sm.handle_event(Event.SCANNING_TIME)
Ejemplo n.º 26
0
 def testPatrolling_StartPatrol(self):
     sm = StateMachine()
     sm.handle_event(Event.START_PATROL)
     with self.assertRaises(InvalidEventException,
                            msg="PATROLLING + START_PATROL is not valid"):
         sm.handle_event(Event.START_PATROL)
Ejemplo n.º 27
0
 def testIdle_DonePatrolling(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + DONE_PATROLLING is not valid"):
         sm.handle_event(Event.DONE_PATROLLING)
Ejemplo n.º 28
0
 def testIdle_DoneScanning(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + DONE_SCANNING is not valid"):
         sm.handle_event(Event.DONE_SCANNING)
Ejemplo n.º 29
0
 def testIdle_ScanningTime(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + SCANNING_TIME is not valid"):
         sm.handle_event(Event.SCANNING_TIME)
Ejemplo n.º 30
0
 def testIdle_ArrivedAtBase(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + ARRIVED_AT_BASE is not valid"):
         sm.handle_event(Event.ARRIVED_AT_BASE)