class Test(TestCase): MapParser.MapParser() def TestSeoulPop(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Seoul": info = cityinfo break self.assertEqual(info.population, 24200000) def TestSeoulDis(self): key = 0 for item in GraphLibrary.route_list: if item.startportcode == 'ICN' and item.endportcode == 'TYO': key = item.distance self.assertEqual(key, 1207) def TestSeoulCon(self): key = False for city in GraphLibrary.Asia: if city == "Seoul": key = True self.assertEqual(key, True) def TestLACountry(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Los Angeles": info = cityinfo break self.assertEqual(info.country, "US") def TestLATimezone(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Los Angeles": info = cityinfo break self.assertEqual(info.timezone, -8) def TestParisRegion(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Paris": info = cityinfo break self.assertEqual(info.region, 3) def TestshortestLength(self): key = QueryData.shortestflight() self.assertEqual(key, 334) def TestaveragePop(self): key = QueryData.averagecitysize() self.assertEqual(key, 11796143) def TestremoveCity(self): EditRoute.removecity("Seoul") isValid = True for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Seoul": isValid = False break self.assertTrue(isValid) # Test for assignment 2.1 def TesteditCountry(self): info = None EditRoute.editcountry("Madrid", "America") isValid = True for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Madrid": info = cityinfo break self.assertEqual(info.country, "America") def TestremoveRoute(self): EditRoute.removeroute("Los Angeles", "San Francisco") isValid = True code = QueryData.nametocode("Los Angeles") code2 = QueryData.nametocode("San Francisco") for route in GraphLibrary.route_list: if route.startportcode == code and route.endportcode == code2: isValid = False break self.assertTrue(isValid) def TestaddCity(self): EditRoute.addcity("LOR", "Minas Tirith", "Gondor", "Europe", "-3", "40", "50", "2034923", "5") isValid = False for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Minas Tirith": isValid = True break self.assertTrue(isValid) def TestaddRoute(self): code = QueryData.nametocode("Los Angeles") code2 = QueryData.nametocode("Seoul") EditRoute.addroute(code, code2, "12435") isValid = False for route in GraphLibrary.route_list: if route.startportcode == code and route.endportcode == code2: isValid = True break self.assertTrue(isValid) def TestChampaign(self): MapParser.newMapParser() isValid = False for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Champaign": isValid = True break self.assertTrue(isValid)
__author__ = 'MyPrecious' import RouteInfo, EditRoute, SaveFile, QueryData, MapParser, GraphLibrary MapParser.MapParser() s = "Type the number for corresponding options:\n" \ "1. Get all the cities from CSAir\n" \ "2. Get a specific information about one city\n" \ "3. Get all kinds of stats\n" \ "4. Get a specific route\n" \ "5. Edit the current city's information\n" \ "6. Add/Remove cities and routes\n" \ "7. Save the changed list to JSON File\n" \ "8. Calculuate the total flight\n" \ "9. Update CSAir with new Champaign hub town\n" \ "10. Calculate the shortest route between to cities.\n" \ "0. Exit the program" while True: print s i = raw_input("Enter the number.") i = int(i) if i == 1: cityList = QueryData.citylist() print "Here are the lists!" for city in cityList: print city
class Test(TestCase): MapParser.MapParser() def TestSeoulPop(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Seoul": info = cityinfo break self.assertEqual(info.population, 24200000) def TestSeoulDis(self): key = 0 for item in GraphLibrary.route_list: if item.startportcode == 'ICN' and item.endportcode == 'TYO': key = item.distance self.assertEqual(key, 1207) def TestSeoulCon(self): key = False for city in GraphLibrary.Asia: if city == "Seoul": key = True self.assertEqual(key, True) def TestLACountry(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Los Angeles": info = cityinfo break self.assertEqual(info.country, "US") def TestLATimezone(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Los Angeles": info = cityinfo break self.assertEqual(info.timezone, -8) def TestParisRegion(self): key = 0 info = None for cityname, cityinfo in GraphLibrary.city_dictionary.iteritems(): if cityname == "Paris": info = cityinfo break self.assertEqual(info.region, 3) def TestshortestLength(self): key = QueryData.shortestflight() self.assertEqual(key, 334) def TestaveragePop(self): key = QueryData.averagecitysize() self.assertEqual(key, 11796143)
def start(self): MapParser.MapParser() s = "Type the number for corresponding options:\n" \ "1. Get all the cities from CSAir\n" \ "2. Get a specific information about one city\n" \ "3. Get all kinds of stats\n" \ "4. Get a specific route\n" \ "5. Edit the current city's information\n" \ "6. Add/Remove cities and routes\n" \ "7. Save the changed list to JSON File\n" \ "8. Calculuate the total flight\n" \ "9. Update CSAir with new Champaign hub town\n" \ "10. Calculate the shortest route between to cities.\n" \ "0. Exit the program" while True: print s i = raw_input("Enter the number.") i = int(i) if i == 1: cityList = QueryData.citylist() print "Here are the lists!" for city in cityList: print city elif i == 2: city_name = raw_input("Enter the city name.") valid = QueryData.getcitydata(city_name) if valid == False: print "No such city." elif i == 3: QueryData.getstat() elif i == 4: city_code = raw_input("Enter the city code.") valid = QueryData.getroute(city_code) if valid == False: print "No such code." elif i == 5: EditRoute.editnetwork() elif i == 6: EditRoute.addnetwork() elif i == 7: SaveFile.saveFile() elif i == 8: RouteInfo.routeinfo() elif i == 9: MapParser.newMapParser() elif i == 10: self.routeInfo.shortestroute() elif i == 0: print "See ya!" break else: print "Invalid Number!"