Esempio n. 1
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")
Esempio n. 2
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")
Esempio n. 3
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")
Esempio n. 4
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")
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 15
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")
Esempio n. 16
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")
Esempio n. 17
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")
Esempio n. 18
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")
Esempio n. 19
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)
Esempio n. 20
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)
Esempio n. 21
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)
Esempio n. 22
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)
Esempio n. 23
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)
Esempio n. 24
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)
Esempio n. 25
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)
Esempio n. 26
0
 def testCreate(self):
     sm = StateMachine()
     self.assertEqual(sm.get_state(), State.IDLE,
                      "When created should be in IDLE state.")
     self.assertNotEqual(
         sm.get_state(), State.PATROLLING,
         "Ensure that the IDLE state is not the same as the PATROLLING state"
     )
     self.assertNotEqual(
         sm.get_state(), State.RETURNING_TO_BASE,
         "Ensure that the IDLE state is not the same as the RETURNING_TO_BASE state"
     )
     self.assertNotEqual(
         sm.get_state(), State.CHARGING,
         "Ensure that the IDLE state is not the same as the CHARGING state")
     self.assertNotEqual(
         sm.get_state(), State.SCARING,
         "Ensure that the IDLE state is not the same as the SCARING state")
     self.assertNotEqual(
         sm.get_state(), State.SCANNING,
         "Ensure that the IDLE state is not the same as the SCANNING state")
Esempio n. 27
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)
Esempio n. 28
0
 def testIdle_DonePatrolling(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + DONE_PATROLLING is not valid"):
         sm.handle_event(Event.DONE_PATROLLING)
Esempio n. 29
0
 def testIdle_DoneScanning(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + DONE_SCANNING is not valid"):
         sm.handle_event(Event.DONE_SCANNING)
Esempio n. 30
0
 def testIdle_ScanningTime(self):
     sm = StateMachine()
     with self.assertRaises(InvalidEventException,
                            msg="IDLE + SCANNING_TIME is not valid"):
         sm.handle_event(Event.SCANNING_TIME)