コード例 #1
0
    def _run_ignored_or_rejected_test(self, status):
        order = self.order

        tel_aviv = self.tel_aviv_station
        tel_aviv_ws1 = tel_aviv.work_stations.all()[0]
        tel_aviv_ws2 = tel_aviv.work_stations.all()[1]

        tel_aviv_2 = create_another_TLV_station()
        tel_aviv_ws3 = tel_aviv_2.work_stations.all()[0]

        resuscitate_work_stations()

        # create an IGNORED/REJECTED assignment by first station (ws1, ws2), should get ws3
        assignment = OrderAssignment(order=order,
                                     station=tel_aviv,
                                     work_station=tel_aviv_ws1,
                                     status=status)
        assignment.save()
        ws_list = compute_ws_list(order)
        self.assertTrue(
            tel_aviv_ws1 not in ws_list and tel_aviv_ws2 not in ws_list,
            "this station ignored the order.")

        next_ws = choose_workstation(order)
        self.assertTrue(next_ws == tel_aviv_ws3, "tel aviv ws3 is expected.")

        # create an IGNORED/REJECTED assignment by ws3, should get None
        assignment = OrderAssignment(order=order,
                                     station=tel_aviv_2,
                                     work_station=tel_aviv_ws3,
                                     status=status)
        assignment.save()
        refresh_order(order)
        self.assertTrue(
            choose_workstation(order) is None, "no ws is expected.")
コード例 #2
0
ファイル: tests.py プロジェクト: WAYbetter/waybetter
    def _run_ignored_or_rejected_test(self, status):
        order = self.order

        tel_aviv = self.tel_aviv_station
        tel_aviv_ws1 = tel_aviv.work_stations.all()[0]
        tel_aviv_ws2 = tel_aviv.work_stations.all()[1]

        tel_aviv_2 = create_another_TLV_station()
        tel_aviv_ws3 = tel_aviv_2.work_stations.all()[0]

        resuscitate_work_stations()

        # create an IGNORED/REJECTED assignment by first station (ws1, ws2), should get ws3
        assignment = OrderAssignment(order=order, station=tel_aviv, work_station=tel_aviv_ws1, status=status)
        assignment.save()
        ws_list = compute_ws_list(order)
        self.assertTrue(tel_aviv_ws1 not in ws_list and tel_aviv_ws2 not in ws_list, "this station ignored the order.")

        next_ws = choose_workstation(order)
        self.assertTrue(next_ws == tel_aviv_ws3, "tel aviv ws3 is expected.")

        # create an IGNORED/REJECTED assignment by ws3, should get None
        assignment = OrderAssignment(order=order, station=tel_aviv_2, work_station=tel_aviv_ws3, status=status)
        assignment.save()
        refresh_order(order)
        self.assertTrue(choose_workstation(order) is None, "no ws is expected.")
コード例 #3
0
    def test_choose_workstation_order(self):
        order = self.order
        resuscitate_work_stations()

        station1 = self.tel_aviv_station  # should have 2 work stations (from fixtures)
        station2 = create_another_TLV_station(num_of_ws=2)

        resuscitate_work_stations()

        ws_list = compute_ws_list(order)

        # stations should alternate
        self.assertTrue(
            ws_list[0].station == ws_list[2].station
            and ws_list[1].station == ws_list[3].station,
            "stations should alternate")

        # work stations should alternate
        self.assertTrue(ws_list[0] != ws_list[2] and ws_list[1] != ws_list[3],
                        "work stations should alternate")

        #
        # scenario: station x -> station y (reject) -> station x
        #
        order = create_test_order()
        first_ws = choose_workstation(order)
        second_ws = choose_workstation(order)

        assignment = OrderAssignment(order=order,
                                     station=second_ws.station,
                                     work_station=second_ws,
                                     status=REJECTED)
        assignment.save()
        refresh_order(order)

        third_ws = choose_workstation(order)

        self.assertTrue(third_ws.station == first_ws.station)

        #
        # scenario: station x -> station y (not taken) -> station x -> station y other ws
        #
        order = create_test_order()
        first_ws = choose_workstation(order)
        second_ws = choose_workstation(order)

        assignment = OrderAssignment(order=order,
                                     station=second_ws.station,
                                     work_station=second_ws,
                                     status=NOT_TAKEN)
        assignment.save()

        third_ws = choose_workstation(order)
        fourth_ws = choose_workstation(order)

        self.assertTrue(second_ws.station == fourth_ws.station
                        and second_ws != fourth_ws)
コード例 #4
0
    def test_originating_station(self):
        passenger = self.passenger
        order = create_test_order(passenger)

        tel_aviv_station = self.tel_aviv_station
        originating_station = create_another_TLV_station()

        order.originating_station = originating_station
        order.save()

        # set the originating station
        self.client.post(reverse('ordering.order_manager.book_order'),
                         data={"order_id": order.id})
        passenger = Passenger.objects.get(id=passenger.id)  # refresh passenger
        self.assertTrue(
            passenger.originating_station == originating_station,
            "passenger.originating_station should be tel_aviv_station and not %s"
            % passenger.originating_station)
        refresh_order(order)

        # resuscitate work stations and order
        resuscitate_work_stations()
        self.assertTrue(
            choose_workstation(order).station == originating_station,
            "originating station is expected")

        # check originating station overrides last assignment date criteria
        tel_aviv_station.last_assignment_date = datetime.datetime.now()
        tel_aviv_station.save()
        refresh_order(order)
        self.assertTrue(
            choose_workstation(order).station == originating_station,
            "originating station is expected")

        # test same originating and default stations results in one assignment
        passenger.default_station = originating_station
        passenger.save()
        order = refresh_order(order)
        order.passenger = passenger
        order.save()
        self.assertTrue(
            order.passenger.default_station == order.originating_station,
            "originating and default stations are not the same")

        resuscitate_work_stations()
        ws_list = compute_ws_list(order)
        count = ws_list.count(originating_station.work_stations.all()[0])
        self.assertTrue(
            count == 1,
            "originating (==default) station should appear exactly once (got %d)"
            % count)
コード例 #5
0
ファイル: tests.py プロジェクト: WAYbetter/waybetter
    def test_choose_workstation_order(self):
        order = self.order
        resuscitate_work_stations()

        station1 = self.tel_aviv_station # should have 2 work stations (from fixtures)
        station2 = create_another_TLV_station(num_of_ws=2)

        resuscitate_work_stations()
        
        ws_list = compute_ws_list(order)

        # stations should alternate
        self.assertTrue(ws_list[0].station == ws_list[2].station and ws_list[1].station == ws_list[3].station, "stations should alternate")

        # work stations should alternate
        self.assertTrue(ws_list[0] != ws_list[2] and ws_list[1] != ws_list[3], "work stations should alternate")

        #
        # scenario: station x -> station y (reject) -> station x
        #
        order = create_test_order()
        first_ws = choose_workstation(order)
        second_ws = choose_workstation(order)

        assignment = OrderAssignment(order=order, station=second_ws.station, work_station=second_ws, status=REJECTED)
        assignment.save()
        refresh_order(order)

        third_ws = choose_workstation(order)

        self.assertTrue(third_ws.station == first_ws.station)

        #
        # scenario: station x -> station y (not taken) -> station x -> station y other ws
        #
        order = create_test_order()
        first_ws = choose_workstation(order)
        second_ws = choose_workstation(order)

        assignment = OrderAssignment(order=order, station=second_ws.station, work_station=second_ws, status=NOT_TAKEN)
        assignment.save()

        third_ws = choose_workstation(order)
        fourth_ws = choose_workstation(order)

        self.assertTrue(second_ws.station == fourth_ws.station and second_ws != fourth_ws)
コード例 #6
0
ファイル: tests.py プロジェクト: WAYbetter/waybetter
    def test_originating_station(self):
        passenger = self.passenger
        order = create_test_order(passenger)

        tel_aviv_station = self.tel_aviv_station
        originating_station = create_another_TLV_station()

        order.originating_station = originating_station
        order.save()

        # set the originating station
        self.client.post(reverse('ordering.order_manager.book_order'), data={"order_id": order.id})
        passenger = Passenger.objects.get(id=passenger.id) # refresh passenger
        self.assertTrue(passenger.originating_station == originating_station, "passenger.originating_station should be tel_aviv_station and not %s" % passenger.originating_station)
        refresh_order(order)
        
        # resuscitate work stations and order
        resuscitate_work_stations()
        self.assertTrue(choose_workstation(order).station == originating_station, "originating station is expected")

        # check originating station overrides last assignment date criteria
        tel_aviv_station.last_assignment_date = datetime.datetime.now()
        tel_aviv_station.save()
        refresh_order(order)
        self.assertTrue(choose_workstation(order).station == originating_station, "originating station is expected")


        # test same originating and default stations results in one assignment
        passenger.default_station = originating_station
        passenger.save()
        order = refresh_order(order)
        order.passenger = passenger
        order.save()
        self.assertTrue(order.passenger.default_station == order.originating_station, "originating and default stations are not the same")

        resuscitate_work_stations()
        ws_list = compute_ws_list(order)
        count = ws_list.count(originating_station.work_stations.all()[0])
        self.assertTrue(count == 1, "originating (==default) station should appear exactly once (got %d)" % count)