Exemple #1
0
 def test_remove_exception(self):
     #arrange
     dr = Drone("Test drone", class_type=1)
     store = DroneStore()
     #assert
     with self.assertRaises(Exception):
         store.remove(dr)
Exemple #2
0
    def __init__(self, conn):
        # Initialise the stores
        self.drones = DroneStore(conn)
        self.operators = OperatorStore(conn)
        self._conn = conn

        # Initialise the GUI window
        self.root = tk.Tk()
        self.root.title('Drone Allocation and Localisation')
        frame = tk.Frame(self.root)
        frame.pack(padx=10, pady=10)

        # Add in the buttons
        drone_button = tk.Button(frame,
                                 text="View Drones",
                                 command=self.view_drones,
                                 width=40,
                                 padx=5,
                                 pady=5)
        drone_button.pack(side=tk.TOP)
        operator_button = tk.Button(frame,
                                    text="View Operators",
                                    command=self.view_operators,
                                    width=40,
                                    padx=5,
                                    pady=5)
        operator_button.pack(side=tk.TOP)
        exit_button = tk.Button(frame,
                                text="Exit System",
                                command=quit,
                                width=40,
                                padx=5,
                                pady=5)
        exit_button.pack(side=tk.TOP)
Exemple #3
0
 def test_add_success(self):
     #arrange
     dr = Drone("Test drone", class_type=1)
     store = DroneStore()
     #act
     actual = store.add(dr)
     #assert
     self.assertIn(dr.id, store._drones)
Exemple #4
0
 def test_add_exception(self):
     #arrange
     dr = Drone("Test drone", class_type=1)
     store = DroneStore()
     #act
     actual = store.add(dr)
     #assert
     with self.assertRaises(Exception):
         store.add(dr)
Exemple #5
0
    def test_droneAddException(self):
        #Arrange
        store = DroneStore()
        dr = Drone("Dupe")

        store.add(dr)
        
        #Act and Assert
        with self.assertRaises(Exception):
            store.add(dr)
Exemple #6
0
    def test_add_success(self):
        # Arrange
        dr = Drone("drone123")
        store = DroneStore()

        # Act
        store.add(dr)

        # Assert
        self.assertEqual(dr, store.get(dr.id))
Exemple #7
0
    def test_add_success(self):
        # Arrange
        dr = Drone("Test drone")
        store = DroneStore()

        # Act
        store.add(dr)

        # Assert
        self.assertEqual(store.get(1), dr)
 def __init__(self, conn):
     self._drones = DroneStore(conn)
     self._commands = {
         'list': self.list,
         'add': self.add,
         'update': self.update,
         'remove': self.remove,
         'allocate': self.allocate,
         'help': self.help,
     }
Exemple #9
0
    def test_remove_success(self):
        # Arrange
        dr = Drone("drone123")
        store = DroneStore()

        # Act
        store.add(dr)
        store.remove(dr)

        # Assert
        self.assertNotIn(dr.id, store.list_all())
Exemple #10
0
    def test_remove_doesnt_exist(self):
        # Arrange
        dr = Drone("drone123")
        store = DroneStore()

        # Act
        with self.assertRaises(Exception) as ctx:
            store.remove(dr)

        # Assert
        self.assertEqual('Drone does not exist in store', str(ctx.exception))
Exemple #11
0
    def test_DroneStore_add_error(self):
        #Arrange
        dr = Drone("Test Drone")
        store = DroneStore()

        #Act
        act = store.add(dr)

        #Assert
        with self.assertRaises(Exception):
            store.add(dr)
Exemple #12
0
    def test_droneRemoveException(self):
        #Arrange
        store = DroneStore()
        dr = Drone("Test")
        store.add(dr)
        
        store.remove(dr)

        #Act and Assert
        with self.assertRaises(Exception):
            store.remove(dr)
Exemple #13
0
    def test_DroneStore_add(self):
        #Arrange
        dr = Drone("Test Drone")
        store = DroneStore()

        #Act
        act = store.add(dr)
        #print(dr.id in store.list_all()) used to test output

        #Assert
        self.assertEqual(dr.id in store.list_all(), True,
                         "Drone has not been added successfully")
Exemple #14
0
    def test_DroneStore_remove_error(self):
        dr = Drone("Test Drone")
        store = DroneStore()

        #Act
        #act = store.remove(dr)

        #Assert
        with self.assertRaises(Exception) as context:
            store.remove(dr)
        self.assertEqual("Drone does not exist in store",
                         str(context.exception))
Exemple #15
0
    def test_add_already_exists(self):
        # Arrange
        dr = Drone("drone123")
        store = DroneStore()

        # Act
        store.add(dr)
        with self.assertRaises(Exception) as ctx:
            store.add(dr)

        # Assert
        self.assertEqual('Drone already exists in store', str(ctx.exception))
Exemple #16
0
    def test_allocate_success(self):
        # Arrange
        dr = Drone("Test drone", class_type=1)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)

        # Assert
        self.assertTrue(act.is_valid())
Exemple #17
0
    def test_remove_fail(self):
        # Arrange
        dr = Drone("Test drone")
        store = DroneStore()
        errorText = 'Drone does not exist in store'

        # Act
        try:
            store.remove(dr)

        # Assert
        except Exception as ex:
            self.assertEqual(str(ex), errorText)
Exemple #18
0
    def test_has_rescue_endorsement_success(self):
        # Arrange
        dr = Drone("Test drone", rescue=True)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        op.rescue_endorsement = True
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)

        # Assert
        self.assertTrue(act.is_valid())
    def test_has_rescue_endorsement(self):
        # Arrange
        dr = Drone("Test drone", rescue=True)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)

        # Assert
        self.assertFalse(act.is_valid())
        self.assertIn("Operator does not have rescue endorsement", act.messages)
Exemple #20
0
    def test_add_fail(self):
        # Arrange
        dr = Drone("Test drone")
        store = DroneStore()
        errorText = 'Drone already exists in store'

        # Act
        try:
            store.add(dr)
            store.add(dr)

        # Assert
        except Exception as ex:
            self.assertEqual(str(ex), errorText)
Exemple #21
0
    def test_only_one_drone(self):
        # Arrange
        dr = Drone("Test drone", class_type=1)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        op.drone = Drone("Yet another")
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)
        # Assert
        self.assertFalse(act.is_valid())
        self.assertIn("Operator can only control one drone", act.messages)
    def test_holds_correct_license(self):
        # Arrange
        dr = Drone("Test drone", class_type=2)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)

        # Assert
        self.assertFalse(act.is_valid())
        self.assertIn("Operator does not have correct drone license", act.messages)
Exemple #23
0
    def test_commit(self):
        # Arrange
        dr = Drone("Test drone", class_type=1)
        op = Operator()
        op.first_name = "John"
        op.drone_license = 1
        store = DroneStore()

        # Act
        act = store.allocate(dr, op)
        act.commit()

        # Assert
        self.assertEquals(dr.operator, op)
        self.assertEquals(op.drone, dr)
Exemple #24
0
    def test_droneRemove(self):
        #Arrange
        store = DroneStore()
        dr = Drone("Test")
        dr2 = Drone("Test2")
        dr3 = Drone("Test3")
        
        store.add(dr)
        store.add(dr2)
        
        #Act
        store.remove(dr2)

        #Assert
        listy = []
        for i in store.list_all():
            listy.append(store.get(i))

        self.assertIn(dr, listy)
        self.assertNotIn(dr2, listy)
Exemple #25
0
    def test_droneAdd(self):
        # Arrange
        dr = Drone("Tester")
        dr2 = Drone("Tester2")
        dr3 = Drone("Tester3")
        dr4 = Drone("Tester3")
        store = DroneStore()

        #Act
        store.add(dr)
        store.add(dr2)
        store.add(dr3)

        listy = []
        
        #Assert
        for i in store.list_all():
            listy.append(store.get(i))

        self.assertIn(dr, listy)
        self.assertIn(dr2, listy)
        self.assertIn(dr3, listy)
        self.assertNotIn(dr4, listy)