Пример #1
0
 def test_should_raise_error_when_end_primary_vehicle_permit_with_active_secondary_vehicle_permit(
     self, ):
     primary_start_time = timezone.make_aware(datetime(2021, 11, 15))
     primary_end_time = get_end_time(primary_start_time, 6)
     primary_vehicle_permit = ParkingPermitFactory(
         customer=self.customer,
         primary_vehicle=True,
         contract_type=ContractType.FIXED_PERIOD,
         status=ParkingPermitStatus.VALID,
         start_time=primary_start_time,
         end_time=primary_end_time,
         month_count=6,
     )
     secondary_start_time = timezone.make_aware(datetime(
         CURRENT_YEAR, 1, 1))
     secondary_end_time = get_end_time(secondary_start_time, 2)
     ParkingPermitFactory(
         customer=self.customer,
         contract_type=ContractType.FIXED_PERIOD,
         status=ParkingPermitStatus.VALID,
         start_time=secondary_start_time,
         end_time=secondary_end_time,
         month_count=2,
     )
     with self.assertRaises(PermitCanNotBeEnded):
         primary_vehicle_permit.end_permit(
             ParkingPermitEndType.AFTER_CURRENT_PERIOD)
Пример #2
0
    def test_should_return_correct_end_time_of_current_time(self):
        start_time = timezone.make_aware(datetime(2021, 11, 15))
        end_time = get_end_time(start_time, 6)
        permit = ParkingPermitFactory(
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        self.assertEqual(
            permit.current_period_end_time,
            timezone.make_aware(
                datetime(CURRENT_YEAR, 2, 14, 23, 59, 59, 999999)),
        )

        start_time = timezone.make_aware(datetime(2021, 11, 20))
        end_time = get_end_time(start_time, 6)
        permit = ParkingPermitFactory(
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        self.assertEqual(
            permit.current_period_end_time,
            timezone.make_aware(
                datetime(CURRENT_YEAR, 2, 19, 23, 59, 59, 999999)),
        )
 def test_second_permit_can_have_upto_12_month_if_primary_is_open_ended(self):
     customer = CustomerFactory()
     ParkingPermitFactory(customer=customer)
     secondary = ParkingPermitFactory(customer=customer, primary_vehicle=False)
     data = {"month_count": 12, "contract_type": FIXED_PERIOD}
     permit_id = str(secondary.id)
     CustomerPermit(customer.id).update(data, permit_id=permit_id)
     secondary.refresh_from_db()
     self.assertEqual(secondary.month_count, 12)
 def setUp(self):
     customer_1 = CustomerFactory(first_name="Firstname B",
                                  last_name="Lastname 1")
     customer_2 = CustomerFactory(first_name="Firstname A",
                                  last_name="Lastname 2")
     customer_3 = CustomerFactory(first_name="Firstname A",
                                  last_name="Lastname 3")
     ParkingPermitFactory(customer=customer_1)
     ParkingPermitFactory(customer=customer_2)
     ParkingPermitFactory(customer=customer_3)
 def setUp(self):
     customer_1 = CustomerFactory(first_name="Firstname B",
                                  last_name="Lastname 1")
     customer_2 = CustomerFactory(first_name="Firstname A",
                                  last_name="Lastname 2")
     customer_3 = CustomerFactory(first_name="Firstname A",
                                  last_name="Lastname 3")
     ParkingPermitFactory(customer=customer_1,
                          status=ParkingPermitStatus.DRAFT)
     ParkingPermitFactory(customer=customer_2,
                          status=ParkingPermitStatus.VALID)
     ParkingPermitFactory(customer=customer_3,
                          status=ParkingPermitStatus.DRAFT)
    def setUp(self):
        self.customer_a = CustomerFactory(first_name="Firstname A", last_name="")
        self.customer_b = CustomerFactory(first_name="Firstname B", last_name="")

        self.c_a_closed = ParkingPermitFactory(customer=self.customer_a, status=CLOSED)
        self.c_a_payment_in_progress = ParkingPermitFactory(
            customer=self.customer_a, status=PAYMENT_IN_PROGRESS
        )
        self.c_a_draft = ParkingPermitFactory(
            customer=self.customer_a, status=DRAFT, primary_vehicle=False
        )
        self.c_a_valid = ParkingPermitFactory(customer=self.customer_a, status=VALID)
        self.c_b_draft = ParkingPermitFactory(customer=self.customer_b, status=DRAFT)
 def test_order_view_should_update_order_and_permits_status(self):
     talpa_order_id = "D86CA61D-97E9-410A-A1E3-4894873B1B35"
     permit_1 = ParkingPermitFactory(status=ParkingPermitStatus.PAYMENT_IN_PROGRESS)
     permit_2 = ParkingPermitFactory(status=ParkingPermitStatus.PAYMENT_IN_PROGRESS)
     order = OrderFactory(talpa_order_id=talpa_order_id, status=OrderStatus.DRAFT)
     order.permits.add(permit_1, permit_2)
     url = reverse("parking_permits:order-notify")
     data = {"eventType": "PAYMENT_PAID", "orderId": talpa_order_id}
     response = self.client.post(url, data)
     self.assertEqual(response.status_code, 200)
     order.refresh_from_db()
     permit_1.refresh_from_db()
     permit_2.refresh_from_db()
     self.assertEqual(order.status, OrderStatus.CONFIRMED)
     self.assertEqual(permit_1.status, ParkingPermitStatus.VALID)
     self.assertEqual(permit_1.status, ParkingPermitStatus.VALID)
Пример #8
0
    def test_get_unused_order_items_return_unused_items(self):
        product_detail_list = [
            [(date(2021, 1, 1), date(2021, 6, 30)),
             Decimal("20")],
            [(date(2021, 7, 1), date(2021, 12, 31)),
             Decimal("30")],
        ]
        self._create_zone_products(self.zone_a, product_detail_list)
        start_time = timezone.make_aware(datetime(2021, 1, 1))
        end_time = get_end_time(start_time, 12)
        permit = ParkingPermitFactory(
            customer=self.customer,
            parking_zone=self.zone_a,
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=12,
        )
        Order.objects.create_for_permits([permit])
        permit.refresh_from_db()
        permit.status = ParkingPermitStatus.VALID
        permit.save()

        with freeze_time(datetime(2021, 4, 15)):
            unused_items = permit.get_unused_order_items()
            self.assertEqual(len(unused_items), 2)
            self.assertEqual(unused_items[0][0].unit_price, Decimal("20"))
            self.assertEqual(unused_items[0][1], 2)
            self.assertEqual(unused_items[0][2],
                             (date(2021, 5, 1), date(2021, 6, 30)))
            self.assertEqual(unused_items[1][0].unit_price, Decimal("30"))
            self.assertEqual(unused_items[1][1], 6)
            self.assertEqual(unused_items[1][2],
                             (date(2021, 7, 1), date(2021, 12, 31)))
Пример #9
0
    def test_parking_permit_change_price_list_when_prices_go_down(self):
        zone_a_product_list = [
            [(date(2021, 1, 1), date(2021, 6, 30)),
             Decimal("20")],
            [(date(2021, 7, 1), date(2021, 12, 31)),
             Decimal("30")],
        ]
        self._create_zone_products(self.zone_a, zone_a_product_list)
        zone_b_product_list = [
            [(date(2021, 1, 1), date(2021, 6, 30)),
             Decimal("30")],
            [(date(2021, 7, 1), date(2021, 12, 31)),
             Decimal("40")],
        ]
        self._create_zone_products(self.zone_b, zone_b_product_list)
        high_emission_vehicle = VehicleFactory()

        start_time = timezone.make_aware(datetime(2021, 1, 1))
        end_time = get_end_time(start_time, 12)
        permit = ParkingPermitFactory(
            customer=self.customer,
            parking_zone=self.zone_a,
            vehicle=high_emission_vehicle,
            contract_type=ContractType.FIXED_PERIOD,
            status=ParkingPermitStatus.VALID,
            start_time=start_time,
            end_time=end_time,
            month_count=12,
        )
        with freeze_time(datetime(2021, 4, 15)):
            price_change_list = permit.get_price_change_list(self.zone_b, True)
            self.assertEqual(len(price_change_list), 2)
            self.assertEqual(price_change_list[0]["product"],
                             "Pysäköintialue B")
            self.assertEqual(price_change_list[0]["previous_price"],
                             Decimal("20"))
            self.assertEqual(price_change_list[0]["new_price"], Decimal("15"))
            self.assertEqual(price_change_list[0]["price_change"],
                             Decimal("-5"))
            self.assertEqual(price_change_list[0]["price_change_vat"],
                             Decimal("-1.2"))
            self.assertEqual(price_change_list[0]["month_count"], 2)
            self.assertEqual(price_change_list[0]["start_date"],
                             date(2021, 5, 1))
            self.assertEqual(price_change_list[0]["end_date"],
                             date(2021, 6, 30))
            self.assertEqual(price_change_list[1]["product"],
                             "Pysäköintialue B")
            self.assertEqual(price_change_list[1]["previous_price"],
                             Decimal("30"))
            self.assertEqual(price_change_list[1]["new_price"], Decimal("20"))
            self.assertEqual(price_change_list[1]["price_change"],
                             Decimal("-10"))
            self.assertEqual(price_change_list[1]["price_change_vat"],
                             Decimal("-2.4"))
            self.assertEqual(price_change_list[1]["month_count"], 6)
            self.assertEqual(price_change_list[1]["start_date"],
                             date(2021, 7, 1))
            self.assertEqual(price_change_list[1]["end_date"],
                             date(2021, 12, 31))
Пример #10
0
 def test_get_products_with_quantities_should_return_products_with_quantities_for_fix_period_with_mid_month_start(
     self, ):
     product_detail_list = [
         [(date(2021, 1, 10), date(2021, 5, 9)),
          Decimal("30")],
         [(date(2021, 5, 10), date(2021, 8, 9)),
          Decimal("30")],
         [(date(2021, 8, 10), date(2021, 12, 31)),
          Decimal("30")],
     ]
     products = self._create_zone_products(self.zone_a, product_detail_list)
     start_time = timezone.make_aware(datetime(2021, 2, 15))
     end_time = get_end_time(start_time, 10)  # ends at 2021-2-14, 23:59
     permit = ParkingPermitFactory(
         parking_zone=self.zone_a,
         contract_type=ContractType.FIXED_PERIOD,
         start_time=start_time,
         end_time=end_time,
         month_count=10,
     )
     products_with_quantities = permit.get_products_with_quantities()
     self.assertEqual(products_with_quantities[0][0].id, products[0].id)
     self.assertEqual(products_with_quantities[0][1], 3)
     self.assertEqual(products_with_quantities[1][0].id, products[1].id)
     self.assertEqual(products_with_quantities[1][1], 3)
     self.assertEqual(products_with_quantities[2][0].id, products[2].id)
     self.assertEqual(products_with_quantities[2][1], 4)
Пример #11
0
    def test_get_refund_amount_for_unused_items_should_return_correct_total(
            self):
        product_detail_list = [
            [(date(2021, 1, 1), date(2021, 6, 30)),
             Decimal("20")],
            [(date(2021, 7, 1), date(2021, 12, 31)),
             Decimal("30")],
        ]
        self._create_zone_products(self.zone_a, product_detail_list)
        start_time = timezone.make_aware(datetime(2021, 1, 1))
        end_time = get_end_time(start_time, 12)
        permit = ParkingPermitFactory(
            customer=self.customer,
            parking_zone=self.zone_a,
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=12,
        )
        order = Order.objects.create_for_permits([permit])
        order.status = OrderStatus.CONFIRMED
        order.save()
        permit.refresh_from_db()
        permit.status = ParkingPermitStatus.VALID
        permit.save()

        with freeze_time(datetime(2021, 4, 15)):
            refund_amount = permit.get_refund_amount_for_unused_items()
            self.assertEqual(refund_amount, Decimal("220"))
Пример #12
0
 def test_customer_has_closed_permit_modified_more_than_two_years_ago_can_be_deleted(
     self,
 ):
     with freeze_time(timezone.make_aware(datetime(2020, 12, 31))):
         customer = CustomerFactory()
         ParkingPermitFactory(customer=customer, status=ParkingPermitStatus.CLOSED)
     with freeze_time(timezone.make_aware(datetime(2022, 12, 31, 0, 0, 1))):
         self.assertTrue(customer.can_be_deleted)
 def test_non_draft_permit_contract_type_can_not_be_edited(self):
     customer = CustomerFactory(first_name="Customer 2", last_name="")
     permit = ParkingPermitFactory(customer=customer, status=VALID)
     data = {"contract_type": FIXED_PERIOD}
     permit_id = str(permit.id)
     msg = "This is not a draft permit and can not be edited"
     with self.assertRaisesMessage(NonDraftPermitUpdateError, msg):
         CustomerPermit(customer.id).update(data, permit_id=permit_id)
 def test_primary_permit_can_have_max_12_month(self):
     customer = CustomerFactory(first_name="Customer", last_name="")
     permit = ParkingPermitFactory(customer=customer, contract_type=FIXED_PERIOD)
     data = {"month_count": 13, "contract_type": FIXED_PERIOD}
     permit_id = str(permit.id)
     CustomerPermit(customer.id).update(data, permit_id=permit_id)
     permit.refresh_from_db()
     self.assertEqual(permit.month_count, 12)
 def test_set_month_count_to_1_for_open_ended_contract(self):
     customer = CustomerFactory(first_name="Customer a", last_name="")
     permit = ParkingPermitFactory(customer=customer, contract_type=FIXED_PERIOD)
     data = {"month_count": 3, "contract_type": OPEN_ENDED}
     permit_id = str(permit.id)
     CustomerPermit(customer.id).update(data, permit_id=permit_id)
     permit.refresh_from_db()
     self.assertEqual(permit.month_count, 1)
 def test_get_changed_reversion_comment(self):
     with reversion.create_revision():
         permit = ParkingPermitFactory(status=ParkingPermitStatus.DRAFT)
     with reversion.create_revision():
         permit.status = ParkingPermitStatus.VALID
         permit.save(update_fields=["status"])
         comment = get_reversion_comment(EventType.CHANGED, permit)
         self.assertEqual(comment, "CHANGED|Status: DRAFT --> VALID")
    def test_secondary_permit_can_be_either_open_ended_or_fixed_if_primary_is_open_ended(
        self,
    ):
        customer = CustomerFactory(first_name="Fake", last_name="")
        ParkingPermitFactory(customer=customer, status=VALID)
        secondary = ParkingPermitFactory(
            customer=customer,
            primary_vehicle=False,
        )
        permit_id = str(secondary.id)
        data = {"contract_type": OPEN_ENDED}
        CustomerPermit(customer.id).update(data, permit_id=permit_id)
        secondary.refresh_from_db()
        self.assertEqual(secondary.contract_type, OPEN_ENDED)

        data1 = {"contract_type": FIXED_PERIOD}
        CustomerPermit(customer.id).update(data1, permit_id=permit_id)
        secondary.refresh_from_db()
        self.assertEqual(secondary.contract_type, FIXED_PERIOD)
 def test_customer_should_not_get_closed_permit(self):
     customer = CustomerFactory(first_name="Firstname", last_name="Lastname")
     ParkingPermitFactory(
         customer=customer,
         status=CLOSED,
         primary_vehicle=True,
         parking_zone=self.zone,
     )
     permits = CustomerPermit(customer.id).get()
     self.assertEqual(len(permits), 0)
Пример #19
0
 def test_customer_has_end_time_recently_can_not_be_deleted(self):
     with freeze_time(timezone.make_aware(datetime(2020, 12, 31))):
         customer = CustomerFactory()
         ParkingPermitFactory(
             customer=customer,
             status=ParkingPermitStatus.CLOSED,
             end_time=timezone.make_aware(datetime(2021, 12, 31)),
         )
     with freeze_time(timezone.make_aware(datetime(2022, 12, 31, 0, 0, 1))):
         self.assertFalse(customer.can_be_deleted)
 def test_second_permit_can_not_have_permit_more_then_primary_if_primary_is_fixed_period(
     self,
 ):
     customer = CustomerFactory()
     ParkingPermitFactory(
         customer=customer,
         status=VALID,
         month_count=5,
         contract_type=FIXED_PERIOD,
         end_time=get_end_time(next_day(), 5),
     )
     secondary = ParkingPermitFactory(
         customer=customer, primary_vehicle=False, contract_type=FIXED_PERIOD
     )
     data = {"month_count": 12, "contract_type": FIXED_PERIOD}
     permit_id = str(secondary.id)
     CustomerPermit(customer.id).update(data, permit_id=permit_id)
     secondary.refresh_from_db()
     self.assertEqual(secondary.month_count, 5)
    def test_secondary_permit_can_be_only_fixed_if_primary_is_fixed_period(self):
        customer = CustomerFactory(first_name="Customer 1", last_name="")
        ParkingPermitFactory(
            customer=customer, status=VALID, contract_type=FIXED_PERIOD
        )
        secondary = ParkingPermitFactory(
            customer=customer, primary_vehicle=False, contract_type=FIXED_PERIOD
        )

        permit_id = str(secondary.id)
        msg = "Only FIXED_PERIOD is allowed"
        with self.assertRaisesMessage(InvalidContractType, msg):
            data = {"contract_type": OPEN_ENDED}
            CustomerPermit(customer.id).update(data, permit_id=permit_id)

        data1 = {"contract_type": FIXED_PERIOD}
        CustomerPermit(customer.id).update(data1, permit_id=permit_id)
        secondary.refresh_from_db()
        self.assertEqual(secondary.contract_type, FIXED_PERIOD)
    def setUp(self):
        self.cus_a = CustomerFactory(first_name="Firstname A", last_name="")
        self.cus_b = CustomerFactory(first_name="Firstname B", last_name="")

        self.c_a_draft = ParkingPermitFactory(
            customer=self.cus_a,
            status=DRAFT,
            address=self.cus_a.primary_address,
            parking_zone=self.cus_a.primary_address.zone,
        )
        self.c_a_can = ParkingPermitFactory(customer=self.cus_a, status=CLOSED)
        self.c_b_valid = ParkingPermitFactory(customer=self.cus_b, status=VALID)
        self.c_b_draft = ParkingPermitFactory(customer=self.cus_b, status=DRAFT)
        self.c_a_draft_sec = ParkingPermitFactory(
            customer=self.cus_a,
            status=DRAFT,
            primary_vehicle=False,
            address=self.cus_a.primary_address,
            parking_zone=self.cus_a.primary_address.zone,
        )
 def setUp(self):
     self.customer_a = CustomerFactory(
         first_name="Firstname A", last_name="Lastname 1"
     )
     self.customer_b = CustomerFactory(
         first_name="Firstname B", last_name="Lastname 2"
     )
     self.customer_c = CustomerFactory(
         first_name="Firstname C", last_name="Lastname 3"
     )
     self.customer_a_zone = self.customer_a.primary_address.zone
     self.zone = ParkingZoneFactory()
     self.vehicle_a = VehicleFactory(power_type=BENSIN)
     ProductFactory(
         zone=self.zone,
         type=ProductType.RESIDENT,
         start_date=date(2022, 1, 1),
         end_date=date(2022, 12, 31),
     )
     ProductFactory(
         zone=self.customer_a_zone,
         type=ProductType.RESIDENT,
         start_date=date(2022, 1, 1),
         end_date=date(2022, 12, 31),
     )
     LowEmissionCriteriaFactory(power_type=BENSIN)
     ParkingPermitFactory(
         customer=self.customer_a,
         status=DRAFT,
         primary_vehicle=True,
         parking_zone=self.customer_a_zone,
         vehicle=self.vehicle_a,
     )
     self.customer_c_valid_primary_permit = ParkingPermitFactory(
         customer=self.customer_c,
         status=VALID,
         primary_vehicle=True,
         contract_type=FIXED_PERIOD,
         parking_zone=self.customer_c.primary_address.zone,
         vehicle=self.vehicle_a,
     )
Пример #24
0
 def test_get_products_with_quantities_raise_error_when_no_product_available_for_open_ended(
     self, ):
     zone = ParkingZoneFactory()
     start_time = timezone.make_aware(datetime(2021, 2, 15))
     permit = ParkingPermitFactory(
         parking_zone=zone,
         contract_type=ContractType.OPEN_ENDED,
         start_time=start_time,
         month_count=1,
     )
     with self.assertRaises(ProductCatalogError):
         permit.get_products_with_quantities()
Пример #25
0
    def test_create_renewable_order_should_create_renewal_order(self):
        start_time = timezone.make_aware(datetime(CURRENT_YEAR, 3, 15))
        end_time = get_end_time(start_time,
                                6)  # end at CURRENT_YEAR-09-14 23:59

        high_emission_vehicle = VehicleFactory(
            power_type=VehiclePowerType.BENSIN,
            emission=100,
            euro_class=6,
            emission_type=EmissionType.WLTP,
        )
        low_emission_vehicle = VehicleFactory(
            power_type=VehiclePowerType.BENSIN,
            emission=70,
            euro_class=6,
            emission_type=EmissionType.WLTP,
        )
        LowEmissionCriteriaFactory(
            start_date=start_time,
            end_date=end_time,
            nedc_max_emission_limit=None,
            wltp_max_emission_limit=80,
            euro_min_class_limit=6,
            power_type=low_emission_vehicle.power_type,
        )
        permit = ParkingPermitFactory(
            parking_zone=self.zone,
            vehicle=high_emission_vehicle,
            customer=self.customer,
            contract_type=ContractType.FIXED_PERIOD,
            status=ParkingPermitStatus.DRAFT,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        order = Order.objects.create_for_permits([permit])
        order.status = OrderStatus.CONFIRMED
        order.save()
        permit.refresh_from_db()
        permit.status = ParkingPermitStatus.VALID
        permit.vehicle = low_emission_vehicle
        permit.save()

        with freeze_time(timezone.make_aware(datetime(CURRENT_YEAR, 5, 5))):
            new_order = Order.objects.create_renewal_order(self.customer)
            order_items = new_order.order_items.all().order_by("start_date")
            self.assertEqual(order_items.count(), 2)
            self.assertEqual(order_items[0].unit_price, Decimal(15))
            self.assertEqual(order_items[0].payment_unit_price, Decimal(-15))
            self.assertEqual(order_items[0].quantity, 2)
            self.assertEqual(order_items[1].unit_price, Decimal(25))
            self.assertEqual(order_items[1].payment_unit_price, Decimal(-25))
            self.assertEqual(order_items[1].quantity, 2)
Пример #26
0
    def test_should_return_correct_months_left(self):
        start_time = timezone.make_aware(datetime(2021, 9, 15))
        end_time = get_end_time(start_time, 6)
        fixed_period_permit_started_2_months_ago = ParkingPermitFactory(
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        self.assertEqual(fixed_period_permit_started_2_months_ago.months_left,
                         3)

        start_time = timezone.make_aware(datetime(2021, 11, 16))
        end_time = get_end_time(start_time, 6)
        fixed_period_permit_start_tomorrow = ParkingPermitFactory(
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        self.assertEqual(fixed_period_permit_start_tomorrow.months_left, 6)

        start_time = timezone.make_aware(datetime(2019, 11, 15))
        end_time = get_end_time(start_time, 6)
        fixed_period_permit_started_2_years_ago = ParkingPermitFactory(
            contract_type=ContractType.FIXED_PERIOD,
            start_time=start_time,
            end_time=end_time,
            month_count=6,
        )
        self.assertEqual(fixed_period_permit_started_2_years_ago.months_left,
                         0)

        start_time = timezone.make_aware(datetime(2019, 11, 15))
        open_ended_permit_started_two_years_ago = ParkingPermitFactory(
            contract_type=ContractType.OPEN_ENDED,
            start_time=start_time,
        )
        self.assertEqual(open_ended_permit_started_two_years_ago.months_left,
                         None)
Пример #27
0
 def test_should_set_end_time_to_now_if_end_permit_immediately(self):
     start_time = timezone.make_aware(datetime(2021, 11, 15))
     end_time = get_end_time(start_time, 6)
     permit = ParkingPermitFactory(
         contract_type=ContractType.FIXED_PERIOD,
         start_time=start_time,
         end_time=end_time,
         month_count=6,
     )
     permit.end_permit(ParkingPermitEndType.IMMEDIATELY)
     self.assertEqual(
         permit.end_time,
         timezone.make_aware(datetime(2021, 11, 20, 12, 10, 50)))
 def setUp(self):
     self.customer_a = CustomerFactory(
         first_name="Firstname A", last_name="Lastname 1"
     )
     self.customer_b = CustomerFactory(
         first_name="Firstname B", last_name="Lastname B"
     )
     self.zone = ParkingZoneFactory()
     self.vehicle_a = VehicleFactory(power_type=VehiclePowerType.BENSIN)
     self.vehicle_b = VehicleFactory(power_type=VehiclePowerType.BENSIN)
     self.vehicle_c = VehicleFactory(power_type=VehiclePowerType.BENSIN)
     ProductFactory(
         zone=self.zone,
         type=ProductType.RESIDENT,
         start_date=date(2022, 1, 1),
         end_date=date(2022, 12, 31),
     )
     LowEmissionCriteriaFactory(power_type=VehiclePowerType.BENSIN)
     ParkingPermitFactory(
         customer=self.customer_a,
         status=DRAFT,
         primary_vehicle=True,
         parking_zone=self.zone,
         vehicle=self.vehicle_a,
     )
     ParkingPermitFactory(
         customer=self.customer_a,
         status=DRAFT,
         primary_vehicle=False,
         parking_zone=self.zone,
         vehicle=self.vehicle_b,
     )
     ParkingPermitFactory(
         customer=self.customer_b,
         status=VALID,
         primary_vehicle=True,
         parking_zone=self.zone,
         vehicle=self.vehicle_b,
     )
Пример #29
0
 def create_customer(self):
     user = UserFactory()
     customer = CustomerFactory(
         user=user,
         source_system=SourceSystem.HELSINKI_PROFILE,
         source_id=self.CUSTOMER_SOURCE_ID,
     )
     ParkingPermitFactory(
         customer=customer,
         status=ParkingPermitStatus.CLOSED,
         end_time=datetime.datetime(2020, 2, 1),
     )
     return customer
Пример #30
0
 def setUp(self):
     self.customer = CustomerFactory(first_name="Firstname A", last_name="")
     ParkingPermitFactory(
         customer=self.customer,
         end_time=timezone.now() + timezone.timedelta(days=1),
         status=ParkingPermitStatus.VALID,
     )
     ParkingPermitFactory(
         customer=self.customer,
         end_time=timezone.now() + timezone.timedelta(days=-1),
         status=ParkingPermitStatus.DRAFT,
     )
     ParkingPermitFactory(
         customer=self.customer,
         end_time=timezone.now() + timezone.timedelta(days=1),
         status=ParkingPermitStatus.DRAFT,
     )
     ParkingPermitFactory(
         customer=self.customer,
         end_time=timezone.now() + timezone.timedelta(days=-1),
         status=ParkingPermitStatus.VALID,
     )