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_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_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_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_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_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 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)
def test_list_all(self): #Arrange m = Map("mappy", "somefilepath") n = Map("flappy", "anotherfilepath") mStore = MapStore() mStore.add(m) mStore.add(n) #Act and Assert listy = [] for i in mStore.list_all(): listy.append(mStore.get(i)) self.assertIn(m, listy) self.assertIn(n, listy)