def test_add_success(self): # Arrange mp = Map("Test map", "") store = MapStore() # Act store.add(mp) # Assert self.assertEqual(store.get("Test map"), mp)
def test_get_fail(self): #Arrange m = Map("mappy", "somefilepath") n = Map("flappy", "anotherfilepath") mStore = MapStore() mStore.add(m) mStore.add(n) #Act and Assert self.assertIsNone(mStore.get("tappy"))
def test_get(self): #Arrange m = Map("mappy", "somefilepath") n = Map("flappy", "anotherfilepath") mStore = MapStore() mStore.add(m) mStore.add(n) #Act and Assert self.assertEquals(m, mStore.get("mappy"))
def test_get_success(self): # Arrange mp = Map("Test map", "") store = MapStore() store.add(mp) # Act act = store.get("Test map") # Assert self.assertEqual(act, mp)
def test_get_fail(self): # Arrange mp = Map("Test map", "") store = MapStore() errorText = 'Map does not exist in store' # Act try: store.get(mp) # Assert except Exception as ex: self.assertEqual(str(ex), errorText)
def test_list_all(self): # Arrange mp1 = Map("Test map 1", "") mp2 = Map("Test map 2", "") store = MapStore() store.add(mp1) store.add(mp2) # Act act = store.list_all() #Assert self.assertEqual(act, ["Test map 1", "Test map 2"])
def test_add_fail(self): # Arrange mp = Map("Test map", "") store = MapStore() errorText = 'Map already exists in store' # Act try: store.add(mp) store.add(mp) # Assert except Exception as ex: self.assertEqual(str(ex), errorText)
def __init__(self, conn): # Initialise the stores self.drones = DroneStore(conn) self.operators = OperatorStore(conn) self.tracking = TrackingSystem() self.maps = MapStore(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) map_button = tk.Button( frame, text="View Map", command=self.view_map, width=40, padx=5, pady=5) map_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)
def test_remove_map_exception(self): #Arrange m = Map("mappy", "somefilepath") n = Map("flappy", "anotherfilepath") mStore = MapStore() mStore.add(m) mStore.add(n) mStore.remove(m) #Act and Assert with self.assertRaises(Exception): mStore.remove(m)
def test_remove_success(self): # Arrange mp = Map("Test map", "") store = MapStore() store.add(mp) # Act store.remove(mp) # Assert self.assertEqual(store.list_all(), [])
def test_add_map_exception(self): #Arrange m = Map("mappy", "somefilepath") mStore = MapStore() mStore.add(m) #Act and Assert with self.assertRaises(Exception): mStore.add(m)
def test_remove_map(self): #Arrange m = Map("mappy", "somefilepath") n = Map("flappy", "anotherfilepath") mStore = MapStore() mStore.add(m) mStore.add(n) #Act mStore.remove(m) #Assert listy = [] for i in mStore.list_all(): listy.append(mStore.get(i)) self.assertNotIn(m, listy)
def test_add_map(self): #Arrange m = Map("mappy", "somefilepath") mStore = MapStore() #Act mStore.add(m) #Assert listy = [] for i in mStore.list_all(): listy.append(mStore.get(i)) self.assertIn(m, listy)