Exemple #1
0
    def test_only_take_station(self):
        """
        Only take the station, no change
        """
        time = datetime(year=2000, month=1, day=1)
        ns1 = MRTStation('NS1', 'NAME1', time)
        ns2 = MRTStation('NS2', 'NAME1', time)
        ns1.add_next_station(ns2)
        ns2.add_next_station(ns1)
        travel_step_1 = TravelStep(ns1, ns1, time, duration=timedelta())
        travel_step_2 = TravelStep(ns1,
                                   ns2,
                                   time,
                                   duration=timedelta(minutes=6))

        travel_plan = TravelPlan()
        travel_plan.step_list.append(travel_step_1)
        travel_plan.step_list.append(travel_step_2)

        readable_plan = travel_plan.get_readable_plan()

        assert readable_plan.is_reachable()
        assert readable_plan.message == 'Total travel time is 6 minutes'
        assert len(readable_plan.step_list) == 1
        step0 = readable_plan.step_list[0]
        assert step0.get_readable_action() == 'Take NS line'

        special_color_list = readable_plan.get_special_color_list()
        assert len(special_color_list) == 1
        assert special_color_list[0] == 'NAME1(NS1)NAME1(NS2)NS'
Exemple #2
0
    def test_only_change_station(self):
        """
        Only change the station, no taking
        """
        time = datetime(year=2000, month=1, day=1)
        ns1 = MRTStation('NS1', 'NAME1', time)
        dt1 = MRTStation('DT1', 'NAME1', time)
        travel_step_1 = TravelStep(ns1, ns1, time, duration=timedelta())
        travel_step_2 = TravelStep(ns1,
                                   dt1,
                                   time,
                                   duration=timedelta(minutes=7))

        travel_plan = TravelPlan()
        travel_plan.step_list.append(travel_step_1)
        travel_plan.step_list.append(travel_step_2)

        readable_plan = travel_plan.get_readable_plan()

        assert readable_plan.is_reachable()
        assert readable_plan.message == 'Total travel time is 7 minutes'
        assert len(readable_plan.step_list) == 1
        step0 = readable_plan.step_list[0]
        assert step0.get_readable_action() == 'Change from NS line to DT line'