def handle_statistics_option(dict_of_edges, dict_of_cities, graph): """ Handles all statistical queries :param dict_of_edges: :param dict_of_cities: :param graph: :return: Nothing """ print("\n---------------------------------------------\n") print("Get Statistical Information about our Route Network") print("\n---------------------------------------------\n") print("\nCurrent options:") print("\n1. Get the longest single flight in the network") print("\n2. Get the shortest single flight in the network") print("\n3. Get the average distance of all the flights in the network") print("\n4. Get the biggest city (by population) served by CSAir") print("\n5. Get the smallest city (by population) served by CSAir") print("\n6. Get the average size (by population) of all the cities served by CSAir") print("\n7. Get a list of the continents served by CSAir and which cities are in them") print("\n8. Get CSAir's hub cities") stat_choice = input("\n\nPlease enter the number of your choice: ") if not str(stat_choice).isdigit() or int(stat_choice)>8 or int(stat_choice)<1: print("Invalid option. Please Try again.") input("Press Enter to Continue.") return if int(stat_choice) == 1: print(Edge.get_longest_flight(dict_of_edges)) if int(stat_choice) == 2: print(Edge.get_shortest_flight(dict_of_edges)) if int(stat_choice) == 3: print("Average Distance: " + str(Edge.get_average_distance(dict_of_edges))) if int(stat_choice) == 4: print(City.get_biggest_city(dict_of_cities)) if int(stat_choice) == 5: print(City.get_smallest_city(dict_of_cities)) if int(stat_choice) == 6: print("Average Population: " + str(City.get_average_population(dict_of_cities))) if int(stat_choice) == 7: print(City.make_dict_of_continents(dict_of_cities)) if int(stat_choice) == 8: print("The Hub cities are:") hub_cities = get_hub_cities(graph) for city in hub_cities: print(dict_of_cities[city].name)
def test_get_biggest_city(self): dict_of_cities = prepare_test_data() answer = City.get_biggest_city(dict_of_cities) self.assertTrue("New York" in answer)