def test_matches_international_i_letters(self): for alpha in 'ыиі': station = Station('К{0}ев'.format(alpha), '') self.assertTrue(station.matches('ы')) self.assertTrue(station.matches('и')) self.assertTrue(station.matches('і'))
def test_matches_international_e_letters(self): for alpha in 'еэє': station = Station('К{0}сів'.format(alpha), '') self.assertTrue(station.matches('е')) self.assertTrue(station.matches('э')) self.assertTrue(station.matches('є'))
def test_two_stations_one_with_same_location(): device = Device(Point(0, 0)) station1 = Station(Point(10, 10), 10) station2 = Station(Point(0, 0), 10) stations = [station1, station2] best_station, power = device.best_station(stations) assert best_station == station2 assert power == 100
def test_two_stations_out_of_reach(): device = Device(Point(20, 20)) station1 = Station(Point(0, 0), 10) station2 = Station(Point(10, 10), 10) stations = [station1, station2] best_station, power = device.best_station(stations) assert best_station == None assert power == 0
def test_load_routes(self): first_station = Station('Краків (Польща)', '2157,2305') second_station = Station('Вінниця (Україна)', '22200') routes = load_routes(first_station, second_station) for route in routes: self.assertEqual(Route, type(route))
def test_one_station_same_location(): device = Device(Point(0, 0)) station = Station(Point(0, 0), 10) stations = [station] best_station, power = device.best_station(stations) assert best_station == station assert power == 100
def test_constructor(self): departure_station = Station("VIL'NO", '') arrival_station = Station('Copenhagen', '') train_route = TrainRoute( departure_station, '23:19', arrival_station, '09:29', '49', "VIL'NO PARMA", '5/09-3/10/2015 DAILY (EXCEPT 6,7,8,9,10,11/09/2015)') self.assertEqual(departure_station, train_route.departure_station) self.assertEqual('23:19', train_route.departure_time) self.assertEqual('09:29', train_route.arrival_time) self.assertEqual(arrival_station, train_route.arrival_station) self.assertEqual('49', train_route.number_train) self.assertEqual("Vil'No Parma", train_route.route) self.assertEqual('5/09-3/10/2015 daily (except 6,7,8,9,10,11/09/2015)', train_route.periodicity)
def set_data(self, solver_data=SolverData(), data=DataStore()): self.data = data self.solver_data = solver_data self.data_set_number = self.solver_data.data_set_number self.time_limit = self.solver_data.time_limit #print("Setting Data Set:", self.data_set_number) self.station = Station() for i in range(self.data.number_of_inbound_trucks): name = 'inbound' + str(i) truck = InboundTruck(name) self.inbound_trucks[name] = truck self.coming_trucks[name] = truck self.all_trucks[name] = truck for i in range(self.data.number_of_outbound_trucks): name = 'outbound' + str(i) truck = OutboundTruck(name) self.outbound_trucks[name] = truck self.going_trucks[name] = truck self.all_trucks[name] = truck for i in range(self.data.number_of_compound_trucks): name = 'compound' + str(i) truck = CompoundTruck(name) self.compound_trucks[name] = truck self.coming_trucks[name] = truck self.going_trucks[name] = truck truck.truck_transfer_time = data.truck_transfer_time self.all_trucks[name] = truck for i in range(self.data.number_of_receiving_doors): name = 'receiving' + str(i) door = ReceivingDoor(name) self.receiving_doors[name] = door door.station = self.station self.all_doors[name] = door self.element_list.append(door) for i in range(self.data.number_of_shipping_doors): name = 'shipping' + str(i) door = ShippingDoor(name) self.shipping_doors[name] = door self.element_list.append(door) self.all_doors[name] = door for truck in self.all_trucks.values(): self.element_list.append(truck) self.set_coming_times() self.set_states() self.set_goods()
def test_station_caps(self): station = Station('ОДЕСА-ГОЛОВНА (УКРАЇНА)', '') self.assertEqual('Одеса-Головна (Україна)', station.name)
def test_constructor(self): station = Station('Lviv', '777') self.assertEqual('Lviv', station.name) self.assertEqual('777', station.id_numbers)
def test_shorten_word_city(self): station = Station('Одеса Місто (Україна)', '') self.assertEqual('Одеса (Україна)', station.name)
def test_shorten_russia(self): station = Station('Москва (Російська Федерація)', '') self.assertEqual('Москва (РФ)', station.name)
def test_matches_complex_international_letters(self): station = Station('КікыкиКєкекэкие', '') self.assertTrue(station.matches('кИкІкЫкЭкЄкЕкиї'))
def test_not_zeroed_points_correct_distance(): station = Station(Point(5, 5), 10) p2 = Point(10, 10) assert round(station.distance(p2), 4) == 7.0711
def test_location_full_power(): station = Station(Point(0, 0), 10) device_location = Point(0, 0) assert station.power(device_location) == 100
def test_doesnt_match_other_letters(self): station = Station('Киев', '') self.assertEqual(False, station.matches('жЖ'))
def test_matches_middle_of_name(self): station = Station('Кишинев', '') self.assertTrue(station.matches('ишинев'))
def test_matches_is_case_insensitive(self): station = Station('Киев', '') self.assertTrue(station.matches('Ки')) self.assertTrue(station.matches('КИ'))
def test_different_points_correct_distance(): station = Station(Point(0, 0), 10) p2 = Point(10, 10) assert round(station.distance(p2), 4) == 14.1421
def test_nearby_location_correct_power(): station = Station(Point(0, 0), 10) device_location = Point(5, 5) assert round(station.power(device_location), 4) == 8.5786
def test_out_of_distance_location_no_power(): station = Station(Point(0, 0), 10) device_location = Point(11, 11) assert station.power(device_location) == 0
def test_same_point_zero_distance(): station = Station(Point(0, 0), 10) p2 = Point(0, 0) assert station.distance(p2) == 0
def setUp(self) -> None: self.test_station_instance = Station()