def test_get_winter_storage_place_with_leases(api_client, lease_status, winter_storage_place): ws_lease = WinterStorageLeaseFactory(place=winter_storage_place) ws_lease.status = lease_status ws_lease.save() expected_is_available = lease_status == LeaseStatus.EXPIRED query = """ { winterStoragePlace(id: "%s") { isAvailable leases { edges { node { id } } } } } """ % to_global_id(WinterStoragePlaceNode._meta.name, winter_storage_place.id) executed = api_client.execute(query) assert executed["data"]["winterStoragePlace"] == { "isAvailable": expected_is_available, "leases": { "edges": [{ "node": { "id": to_global_id(WinterStorageLeaseNode._meta.name, ws_lease.id) } }] }, }
def test_winter_storage_place_is_available_rejected_new_lease(date, inactive_status): with freeze_time(date): old_lease = WinterStorageLeaseFactory( status=LeaseStatus.PAID, start_date=calculate_winter_storage_lease_start_date() - relativedelta(years=1), end_date=calculate_winter_storage_lease_end_date() - relativedelta(years=1), ) WinterStorageLeaseFactory( status=inactive_status, place=old_lease.place, customer=old_lease.customer ) # Need to fetch the berth from the DB to get the annotated value assert WinterStoragePlace.objects.get(id=old_lease.place_id).is_available
def test_create_boats_winter_storage_applications( winter_storage_application_with_customer, ): # Renaming for simplicity application = winter_storage_application_with_customer BoatTypeFactory(id=application.boat_type_id) application.status = ApplicationStatus.OFFER_SENT WinterStorageLeaseFactory( application=application, customer=application.customer, status=LeaseStatus.PAID, boat=None, ) application.save() assert application.customer.boats.count() == 0 call_command("create_boat_for_existing_applications") application.refresh_from_db() assert application.customer.boats.count() == 1 boat = application.customer.boats.first() assert boat.registration_number == application.boat_registration_number assert boat.name == application.boat_name assert boat.model == application.boat_model assert boat.width == application.boat_width assert boat.length == application.boat_length assert application.lease.boat == boat
def test_update_boats_winter_storage_applications( winter_storage_application_with_customer, ): # Renaming for simplicity application = winter_storage_application_with_customer boat_type = BoatTypeFactory(id=application.boat_type_id) application.boat_name = "New name" application.boat_registration_number = "NUMBER" application.status = ApplicationStatus.OFFER_SENT WinterStorageLeaseFactory( application=application, customer=application.customer, status=LeaseStatus.PAID, boat=BoatFactory( owner=application.customer, registration_number="NUMBER", name="Old name", boat_type=boat_type, ), ) application.save() assert application.customer.boats.count() == 1 call_command("create_boat_for_existing_applications") assert application.customer.boats.count() == 1 boat = application.customer.boats.first() assert boat.registration_number == application.boat_registration_number assert boat.name == application.boat_name == "New name"
def test_winter_season_price(): start_date = today() end_date = start_date + relativedelta(days=15) # 1m2 place for simplicity place = WinterStoragePlaceFactory( place_type=WinterStoragePlaceTypeFactory(width=1, length=1)) lease = WinterStorageLeaseFactory(place=place, start_date=start_date, end_date=end_date, create_product=False) WinterStorageProductFactory( price_value=Decimal("10"), winter_storage_area=lease.get_winter_storage_area()) order = OrderFactory(lease=lease) assert order.price == Decimal("10.00")
def test_order_berth_product_winter_storage_lease_raise_error(): lease = WinterStorageLeaseFactory() with pytest.raises(ValidationError) as exception: OrderFactory(product=BerthProductFactory(), lease=lease, customer=lease.customer) errors = str(exception.value) assert "A BerthProduct must be associated with a BerthLease" in errors
def test_order_manager_only_berth_orders(): OrderFactory(lease=BerthLeaseFactory()) OrderFactory(lease=WinterStorageLeaseFactory()) orders = Order.objects.berth_orders() assert orders.count() == 1 for order in orders: assert order.lease.berth is not None
def test_order_manager_only_winter_storage_orders(): OrderFactory(lease=BerthLeaseFactory()) OrderFactory(lease=WinterStorageLeaseFactory()) orders = Order.objects.winter_storage_orders() assert orders.count() == 1 for order in Order.objects.winter_storage_orders(): assert order.lease.place is not None
def test_order_cannot_change_winter_storage_lease(winter_storage_lease): order = OrderFactory(lease=winter_storage_lease, ) with pytest.raises(ValidationError) as exception: order.lease = WinterStorageLeaseFactory( customer=winter_storage_lease.customer) order.save() errors = str(exception.value) assert "Cannot change the lease associated with this order" in errors
def test_winter_storage_place_is_available_ends_during_season( superuser_api_client, winter_storage_place, status ): end_date = calculate_winter_storage_lease_end_date() end_date = end_date.replace(month=end_date.month - 1) WinterStorageLeaseFactory( place=winter_storage_place, end_date=end_date, status=LeaseStatus(status), ) assert WinterStoragePlace.objects.get(id=winter_storage_place.id).is_available
def test_winter_storage_place_is_not_available_renew_pending(date): with freeze_time(date): lease = WinterStorageLeaseFactory( status=LeaseStatus.PAID, start_date=calculate_winter_storage_lease_start_date() - relativedelta(years=1), end_date=calculate_winter_storage_lease_end_date() - relativedelta(years=1), ) # Need to fetch the berth from the DB to get the annotated value assert not WinterStoragePlace.objects.get(id=lease.place_id).is_available
def test_order_right_price_for_non_billable(winter_storage_section, boat, non_billable_customer): boat.owner = non_billable_customer boat.save() winter_storage_lease = WinterStorageLeaseFactory( place=None, section=winter_storage_section, customer=boat.owner, boat=boat) order = OrderFactory(lease=winter_storage_lease) assert order.price == 0 assert order.tax_percentage == 0
def test_order_winter_storage_lease_right_price_for_full_season( winter_storage_area): services = { "summer_storage_for_docking_equipment": True, "summer_storage_for_trailers": random_bool(), } for service, create in services.items(): if create: # Using PriceUnits.AMOUNT to simplify testing AdditionalProductFactory( service=ProductServiceType(service), price_value=Decimal("25.00"), price_unit=PriceUnits.AMOUNT, ) section = WinterStorageSectionFactory(**services, area=winter_storage_area) lease = WinterStorageLeaseFactory( place=WinterStoragePlaceFactory(winter_storage_section=section), create_product=False, ) WinterStorageProductFactory(winter_storage_area=winter_storage_area, price_value=Decimal("100.00")) order = OrderFactory(lease=lease) for service, create in services.items(): if create: additional_product = AdditionalProduct.objects.filter( service=ProductServiceType(service), price_unit=PriceUnits.AMOUNT, period=PeriodType.SEASON, ).first() OrderLine.objects.create(order=order, product=additional_product) assert order.lease.start_date == calculate_winter_storage_lease_start_date( ) assert order.lease.end_date == calculate_winter_storage_lease_end_date() sqm = order.lease.place.place_type.width * order.lease.place.place_type.length expected_price = rounded(Decimal("100.00") * sqm, decimals=2, round_to_nearest=1) assert order.price == expected_price for service, created in services.items(): if created: order_line = OrderLine.objects.filter( order=order, product__service=ProductServiceType(service)).first() assert order_line.price == Decimal("25.00")
def test_order_winter_storage_lease_with_section_right_price( winter_storage_section, boat): winter_storage_lease = WinterStorageLeaseFactory( place=None, section=winter_storage_section, customer=boat.owner, boat=boat) order = OrderFactory(lease=winter_storage_lease) sqm = boat.width * boat.length expected_price = rounded(order.product.price_value * sqm, decimals=2) assert order.lease.id == winter_storage_lease.id assert order._lease_content_type.name == winter_storage_lease._meta.verbose_name assert order.price == expected_price
def test_order_winter_storage_lease_right_price_for_partial_year( winter_storage_area): services = { "summer_storage_for_docking_equipment": True, "summer_storage_for_trailers": random_bool(), } day_offset = 100 for service, create in services.items(): if create: # Using PriceUnits.AMOUNT to simplify testing AdditionalProductFactory( service=ProductServiceType(service), price_unit=PriceUnits.AMOUNT, period=PeriodType.YEAR, ) section = WinterStorageSectionFactory(**services, area=winter_storage_area) lease = WinterStorageLeaseFactory( place=WinterStoragePlaceFactory(winter_storage_section=section), start_date=today(), end_date=today() + timedelta(days=day_offset), ) order = OrderFactory(lease=lease) for service, create in services.items(): if create: product = AdditionalProduct.objects.filter( service=ProductServiceType(service), price_unit=PriceUnits.AMOUNT, period=PeriodType.YEAR, ).first() OrderLine.objects.create(order=order, product=product) assert order.lease.start_date != calculate_berth_lease_start_date() assert order.lease.end_date != calculate_berth_lease_end_date() for service, created in services.items(): if created: order_line = OrderLine.objects.filter( order=order, product__service=ProductServiceType(service)).first() partial_product_price = calculate_product_partial_year_price( order_line.product.price_value, order.lease.start_date, order.lease.end_date, ) order_price = order_line.price assert partial_product_price == order_price
def test_create_winter_storage_contract(visma_sign_service): document_id = str(uuid.uuid4()) invitation_id = str(uuid.uuid4()) passphrase = "test-passphrase" lease = WinterStorageLeaseFactory() with mock.patch( "requests.request", side_effect=mocked_visma_create_contract_requests( document_id, invitation_id, passphrase ), ): contract = visma_sign_service.create_winter_storage_contract(lease) assert contract.document_id == document_id assert contract.invitation_id == invitation_id assert contract.passphrase == passphrase assert contract.lease == lease
def test_order_winter_storage_lease_without_boat_right_price( winter_storage_section, winter_storage_application, customer_profile, ): winter_storage_lease = WinterStorageLeaseFactory( place=None, section=winter_storage_section, customer=customer_profile, boat=None, application=winter_storage_application, ) order = OrderFactory(lease=winter_storage_lease) sqm = winter_storage_application.boat_width * winter_storage_application.boat_length expected_price = rounded(order.product.price_value * sqm, decimals=2) assert order.lease.id == winter_storage_lease.id assert order._lease_content_type.name == winter_storage_lease._meta.verbose_name assert order.price == expected_price
def test_marked_winter_storage_price_rounded(width, length, expected_price): """For a place of 2,4 x 6,0, with the regular price of 11,4e the actual price would be 164,16e. According to the pricing rules, the prices are "rounded" to the nearest integer, in this case 164,00e. Testing all the possible width-length-price combinations according to the pricing table. """ lease = WinterStorageLeaseFactory( place__place_type__width=width, place__place_type__length=length, create_product=False, ) WinterStorageProductFactory( winter_storage_area=lease.place.winter_storage_section.area, price_value=Decimal("11.40"), tax_percentage=Decimal("24.00"), ) order = OrderFactory(lease=lease) assert order.price == Decimal(expected_price)
def test_get_winter_storage_section_with_leases_not_enough_permissions( api_client, winter_storage_section): WinterStorageLeaseFactory(place=None, section=winter_storage_section) query = """ { winterStorageSection(id: "%s") { properties { leases { edges { node { id } } } } } } """ % to_global_id(WinterStorageSectionNode._meta.name, winter_storage_section.id) executed = api_client.execute(query) assert_not_enough_permissions(executed)
def test_order_right_price_for_company(winter_storage_section, boat, company_customer): boat.owner = company_customer # we don't use decimals for width and length in this unit test # it causes random rounding problems when asserting the double price boat.width = 1 boat.length = 4 boat.save() winter_storage_lease = WinterStorageLeaseFactory( place=None, section=winter_storage_section, customer=boat.owner, boat=boat) order = OrderFactory(lease=winter_storage_lease) sqm = boat.width * boat.length # expect double the price expected_price = order.product.price_value * sqm * 2 assert order.price == expected_price assert order.tax_percentage == order.product.tax_percentage
def _get_winter_storage_order_context(subject: str = "Winter storage order"): customer = CustomerProfileFactory.build() order = OrderFactory.build( customer=customer, product=WinterStorageProductFactory.build(), lease=WinterStorageLeaseFactory.build(customer=customer), price=Decimal("100"), tax_percentage=Decimal("24.00"), ) optional_services = [ OrderLineFactory.build( order=order, product__service=ProductServiceType.OPTIONAL_SERVICES()[0], price=random_price(), ), OrderLineFactory.build( order=order, product__service=ProductServiceType.OPTIONAL_SERVICES()[1], price=random_price(), ), ] return _get_order_context(subject, order, optional_services)
def test_get_winter_storage_section_with_leases(api_client, winter_storage_section): ws_lease = WinterStorageLeaseFactory(place=None, section=winter_storage_section) query = """ { winterStorageSection(id: "%s") { properties { leases { edges { node { id } } } } } } """ % to_global_id(WinterStorageSectionNode._meta.name, winter_storage_section.id) executed = api_client.execute(query) assert executed["data"]["winterStorageSection"] == { "properties": { "leases": { "edges": [{ "node": { "id": to_global_id(WinterStorageLeaseNode._meta.name, ws_lease.id) } }] } } }
def _generate_order(order_type: str = None): customer_profile = CustomerProfileFactory() if order_type == "berth_order": order = OrderFactory( customer=customer_profile, lease=BerthLeaseFactory( application=BerthApplicationFactory(), customer=customer_profile, ), ) elif order_type == "winter_storage_order": order = OrderFactory( customer=customer_profile, lease=WinterStorageLeaseFactory( application=WinterStorageApplicationFactory(), customer=customer_profile), ) elif order_type == "unmarked_winter_storage_order": order = OrderFactory( customer=customer_profile, lease=WinterStorageLeaseFactory( application=WinterStorageApplicationFactory( area_type=ApplicationAreaType.UNMARKED), place=None, section=WinterStorageSectionFactory(), customer=customer_profile, ), ) elif order_type == "additional_product_order": order = OrderFactory( order_type=OrderType.ADDITIONAL_PRODUCT_ORDER, customer=customer_profile, price=random_price(), tax_percentage=random_tax(), product=None, lease=BerthLeaseFactory(application=BerthApplicationFactory(), customer=customer_profile), ) elif order_type == "additional_product_order_with_lease_order": lease = BerthLeaseFactory( application=BerthApplicationFactory(), customer=customer_profile, ) OrderFactory( order_type=OrderType.LEASE_ORDER, customer=customer_profile, lease=lease, status=OrderStatus.PAID, ) order = OrderFactory( order_type=OrderType.ADDITIONAL_PRODUCT_ORDER, customer=customer_profile, price=random_price(), tax_percentage=random_tax(), product=None, lease=lease, ) storage_on_ice = PlainAdditionalProductFactory( service=ProductServiceType.STORAGE_ON_ICE, period=PeriodType.SEASON, tax_percentage=Decimal("24.00"), price_value=Decimal("60.00"), price_unit=PriceUnits.PERCENTAGE, ) OrderLineFactory(order=order, product=storage_on_ice, price=Decimal("15.00")) elif order_type == "non_billable_customer_order": OrganizationFactory(customer=customer_profile, organization_type=OrganizationType.NON_BILLABLE) order = OrderFactory(customer=customer_profile, status=OrderStatus.OFFERED) else: # Also covers the case of `order_type == "empty_order"` order = OrderFactory( customer=customer_profile, price=random_price(), tax_percentage=random_tax(), product=None, lease=None, ) return order
def test_winter_storage_place_is_available_next_season(date, status): with freeze_time(date): lease = WinterStorageLeaseFactory(status=status) # Need to fetch the berth from the DB to get the annotated value assert WinterStoragePlace.objects.get(id=lease.place_id).is_available
def test_winter_storage_place_is_not_available_valid_through_whole_season( superuser_api_client, winter_storage_place, status ): WinterStorageLeaseFactory(place=winter_storage_place, status=status) assert not WinterStoragePlace.objects.get(id=winter_storage_place.id).is_available
def test_winter_storage_place_is_available_lease_status( superuser_api_client, winter_storage_place, status ): WinterStorageLeaseFactory(place=winter_storage_place, status=LeaseStatus(status)) assert WinterStoragePlace.objects.get(id=winter_storage_place.id).is_available
def test_order_type_unmarked_winter_storage_order(): order = OrderFactory(lease=WinterStorageLeaseFactory( application=WinterStorageApplicationFactory( area_type=ApplicationAreaType.UNMARKED), ), ) assert order.lease_order_type == LeaseOrderType.UNMARKED_WINTER_STORAGE_ORDER
def test_order_type_winter_storage_order(): order = OrderFactory(lease=WinterStorageLeaseFactory(), ) assert order.lease_order_type == LeaseOrderType.WINTER_STORAGE_ORDER
def test_get_full_profile_information_from_gdpr_api( rest_api_client, requests_mock, settings ): customer_profile = CustomerProfileFactory() boat = BoatFactory(owner=customer_profile) berth_application = BerthApplicationFactory(customer=customer_profile) berth_lease = BerthLeaseFactory( customer=customer_profile, boat=boat, status=LeaseStatus.PAID ) winter_storage_application = WinterStorageApplicationFactory( customer=customer_profile ) winter_storage_lease = WinterStorageLeaseFactory( customer=customer_profile, boat=boat ) order = OrderFactory(lease=berth_lease) berth_switch_offer = BerthSwitchOfferFactory( customer=customer_profile, lease=berth_lease ) organization = OrganizationFactory(customer=customer_profile) auth_header = get_api_token_for_user_with_scopes( customer_profile.user, [settings.GDPR_API_QUERY_SCOPE], requests_mock ) rest_api_client.credentials(HTTP_AUTHORIZATION=auth_header) response = rest_api_client.get( reverse("helsinki_gdpr:gdpr_v1", kwargs={"pk": customer_profile.id}) ) resp = json.loads(response.content) assert response.status_code == 200 assert { "key": "INVOICING_TYPE", "value": dict(InvoicingType.choices)[customer_profile.invoicing_type], } in resp["children"] assert {"key": "COMMENT", "value": customer_profile.comment} in resp["children"] assert { "key": "CREATED_AT", "value": customer_profile.created_at.strftime("%d-%m-%Y %H:%M:%S"), } in resp["children"] assert { "key": "MODIFIED_AT", "value": customer_profile.modified_at.strftime("%d-%m-%Y %H:%M:%S"), } in resp["children"] berth_applications_dict = {} berth_leases_dict = {} boats_dict = {} offers_dict = {} orders_dict = {} organization_dict = {} winter_storage_applications_dict = {} winter_storage_leases_dict = {} for child_dict in resp["children"]: if child_dict["key"] == "BERTH_APPLICATIONS": berth_applications_dict = child_dict elif child_dict["key"] == "BERTH_LEASES": berth_leases_dict = child_dict elif child_dict["key"] == "BOATS": boats_dict = child_dict elif child_dict["key"] == "OFFERS": offers_dict = child_dict elif child_dict["key"] == "ORDERS": orders_dict = child_dict elif child_dict["key"] == "ORGANIZATION": organization_dict = child_dict elif child_dict["key"] == "WINTER_STORAGE_APPLICATIONS": winter_storage_applications_dict = child_dict elif child_dict["key"] == "WINTER_STORAGE_LEASES": winter_storage_leases_dict = child_dict # Using a TestCase here since assertDictEqual is better for comparing dicts test_case = TestCase() test_case.assertDictEqual( { "key": "BERTH_APPLICATIONS", "children": [ { "key": "BERTHAPPLICATION", "children": [ {"key": "ID", "value": berth_application.id}, { "key": "CREATED_AT", "value": berth_application.created_at.strftime( "%d-%m-%Y %H:%M:%S" ), }, { "key": "STATUS", "value": dict(ApplicationStatus.choices)[ berth_application.status ], }, {"key": "LANGUAGE", "value": berth_application.language}, {"key": "FIRST_NAME", "value": berth_application.first_name}, {"key": "LAST_NAME", "value": berth_application.last_name}, {"key": "EMAIL", "value": berth_application.email}, { "key": "PHONE_NUMBER", "value": berth_application.phone_number, }, {"key": "ADDRESS", "value": berth_application.address}, {"key": "ZIP_CODE", "value": berth_application.zip_code}, { "key": "MUNICIPALITY", "value": berth_application.municipality, }, { "key": "COMPANY_NAME", "value": berth_application.company_name, }, {"key": "BUSINESS_ID", "value": berth_application.business_id}, {"key": "BOAT_TYPE", "value": berth_application.boat_type.name}, { "key": "BOAT_REGISTRATION_NUMBER", "value": berth_application.boat_registration_number, }, {"key": "BOAT_NAME", "value": berth_application.boat_name}, {"key": "BOAT_MODEL", "value": berth_application.boat_model}, { "key": "BOAT_LENGTH", "value": float(berth_application.boat_length), }, { "key": "BOAT_WIDTH", "value": float(berth_application.boat_width), }, { "key": "ACCEPT_BOATING_NEWSLETTER", "value": berth_application.accept_boating_newsletter, }, { "key": "ACCEPT_FITNESS_NEWS", "value": berth_application.accept_fitness_news, }, { "key": "ACCEPT_LIBRARY_NEWS", "value": berth_application.accept_library_news, }, { "key": "ACCEPT_OTHER_CULTURE_NEWS", "value": berth_application.accept_other_culture_news, }, { "key": "INFORMATION_ACCURACY_CONFIRMED", "value": berth_application.information_accuracy_confirmed, }, { "key": "APPLICATION_CODE", "value": berth_application.application_code, }, {"key": "HARBORCHOICE_SET", "value": []}, { "key": "BERTH_SWITCH", "value": berth_application.berth_switch, }, { "key": "BOAT_DRAUGHT", "value": berth_application.boat_draught, }, {"key": "BOAT_WEIGHT", "value": berth_application.boat_weight}, { "key": "ACCESSIBILITY_REQUIRED", "value": berth_application.accessibility_required, }, { "key": "BOAT_PROPULSION", "value": berth_application.boat_propulsion, }, { "key": "BOAT_HULL_MATERIAL", "value": berth_application.boat_hull_material, }, { "key": "BOAT_INTENDED_USE", "value": berth_application.boat_intended_use, }, { "key": "RENTING_PERIOD", "value": berth_application.renting_period, }, {"key": "RENT_FROM", "value": berth_application.rent_from}, {"key": "RENT_TILL", "value": berth_application.rent_till}, { "key": "BOAT_IS_INSPECTED", "value": berth_application.boat_is_inspected, }, { "key": "BOAT_IS_INSURED", "value": berth_application.boat_is_insured, }, { "key": "AGREE_TO_TERMS", "value": berth_application.agree_to_terms, }, ], } ], }, berth_applications_dict, ) test_case.assertDictEqual( { "key": "BERTH_LEASES", "children": [ { "key": "BERTHLEASE", "children": [ {"key": "ID", "value": str(berth_lease.id)}, {"key": "BOAT", "value": str(boat.id)}, { "key": "STATUS", "value": dict(LeaseStatus.choices)[berth_lease.status], }, {"key": "ORDERS", "value": [str(order.id)]}, {"key": "COMMENT", "value": berth_lease.comment}, { "key": "BERTH", "value": { "key": "BERTH", "children": [ { "key": "NUMBER", "value": berth_lease.berth.number, }, { "key": "PIER", "value": { "key": "PIER", "children": [ { "key": "IDENTIFIER", "value": berth_lease.berth.pier.identifier, } ], }, }, ], }, }, {"key": "APPLICATION", "value": None}, { "key": "START_DATE", "value": berth_lease.start_date.strftime("%d-%m-%Y"), }, { "key": "END_DATE", "value": berth_lease.end_date.strftime("%d-%m-%Y"), }, ], } ], }, berth_leases_dict, ) test_case.assertDictEqual( { "key": "BOATS", "children": [ { "key": "BOAT", "children": [ {"key": "ID", "value": str(boat.id)}, {"key": "CERTIFICATES", "children": []}, { "key": "REGISTRATION_NUMBER", "value": boat.registration_number, }, {"key": "LENGTH", "value": float(boat.length)}, {"key": "WIDTH", "value": float(boat.width)}, {"key": "DRAUGHT", "value": boat.draught}, ], } ], }, boats_dict, ) test_case.assertDictEqual( { "key": "OFFERS", "children": [ { "key": "BERTHSWITCHOFFER", "children": [ {"key": "ID", "value": str(berth_switch_offer.id)}, { "key": "STATUS", "value": dict(OfferStatus.choices)[ berth_switch_offer.status ], }, { "key": "DUE_DATE", "value": berth_switch_offer.due_date.strftime("%d-%m-%Y") if berth_switch_offer.due_date else None, }, { "key": "CUSTOMER_FIRST_NAME", "value": berth_switch_offer.customer_first_name, }, { "key": "CUSTOMER_LAST_NAME", "value": berth_switch_offer.customer_last_name, }, { "key": "CUSTOMER_EMAIL", "value": berth_switch_offer.customer_email, }, { "key": "CUSTOMER_PHONE", "value": berth_switch_offer.customer_phone, }, { "key": "APPLICATION", "value": berth_switch_offer.application.id, }, {"key": "LEASE", "value": str(berth_switch_offer.lease.id)}, {"key": "BERTH", "value": str(berth_switch_offer.berth.id)}, ], } ], }, offers_dict, ) test_case.assertDictEqual( { "key": "ORDERS", "children": [ { "key": "ORDER", "children": [ {"key": "ID", "value": str(order.id)}, { "key": "PRODUCT", "value": { "key": "BERTHPRODUCT", "children": [ { "key": "MIN_WIDTH", "value": float(order.product.min_width), }, { "key": "MAX_WIDTH", "value": float(order.product.max_width), }, { "key": "TIER_1_PRICE", "value": float(order.product.tier_1_price), }, { "key": "TIER_2_PRICE", "value": float(order.product.tier_2_price), }, { "key": "TIER_3_PRICE", "value": float(order.product.tier_3_price), }, { "key": "PRICE_UNIT", "value": order.product.price_unit, }, { "key": "TAX_PERCENTAGE", "value": float(order.product.tax_percentage), }, ], }, }, {"key": "LEASE", "value": str(order.lease.id)}, { "key": "STATUS", "value": dict(OrderStatus.choices)[order.status], }, {"key": "COMMENT", "value": order.comment}, {"key": "PRICE", "value": float(order.price)}, {"key": "TAX_PERCENTAGE", "value": float(order.tax_percentage)}, {"key": "PRETAX_PRICE", "value": float(order.pretax_price)}, {"key": "TOTAL_PRICE", "value": float(order.total_price)}, { "key": "TOTAL_PRETAX_PRICE", "value": float(order.total_pretax_price), }, { "key": "TOTAL_TAX_PERCENTAGE", "value": float(order.total_tax_percentage), }, { "key": "DUE_DATE", "value": order.due_date.strftime("%d-%m-%Y"), }, {"key": "ORDER_LINES", "children": []}, {"key": "LOG_ENTRIES", "children": []}, {"key": "PAID_AT", "value": None}, {"key": "CANCELLED_AT", "value": None}, {"key": "REJECTED_AT", "value": None}, ], } ], }, orders_dict, ) test_case.assertDictEqual( { "key": "ORGANIZATION", "children": [ {"key": "ID", "value": str(organization.id)}, {"key": "BUSINESS_ID", "value": organization.business_id}, {"key": "NAME", "value": organization.name}, {"key": "ADDRESS", "value": organization.address}, {"key": "POSTAL_CODE", "value": organization.postal_code}, {"key": "CITY", "value": organization.city}, ], }, organization_dict, ) test_case.assertDictEqual( { "key": "WINTER_STORAGE_APPLICATIONS", "children": [ { "key": "WINTERSTORAGEAPPLICATION", "children": [ {"key": "ID", "value": winter_storage_application.id}, { "key": "CREATED_AT", "value": winter_storage_application.created_at.strftime( "%d-%m-%Y %H:%M:%S" ), }, { "key": "STATUS", "value": dict(ApplicationStatus.choices)[ winter_storage_application.status ], }, { "key": "LANGUAGE", "value": winter_storage_application.language, }, { "key": "FIRST_NAME", "value": winter_storage_application.first_name, }, { "key": "LAST_NAME", "value": winter_storage_application.last_name, }, {"key": "EMAIL", "value": winter_storage_application.email}, { "key": "PHONE_NUMBER", "value": winter_storage_application.phone_number, }, {"key": "ADDRESS", "value": winter_storage_application.address}, { "key": "ZIP_CODE", "value": winter_storage_application.zip_code, }, { "key": "MUNICIPALITY", "value": winter_storage_application.municipality, }, {"key": "COMPANY_NAME", "value": ""}, {"key": "BUSINESS_ID", "value": ""}, { "key": "BOAT_TYPE", "value": winter_storage_application.boat_type.name, }, {"key": "BOAT_REGISTRATION_NUMBER", "value": ""}, {"key": "BOAT_NAME", "value": ""}, {"key": "BOAT_MODEL", "value": ""}, { "key": "BOAT_LENGTH", "value": float(winter_storage_application.boat_length), }, { "key": "BOAT_WIDTH", "value": float(winter_storage_application.boat_width), }, {"key": "ACCEPT_BOATING_NEWSLETTER", "value": False}, {"key": "ACCEPT_FITNESS_NEWS", "value": False}, {"key": "ACCEPT_LIBRARY_NEWS", "value": False}, {"key": "ACCEPT_OTHER_CULTURE_NEWS", "value": False}, {"key": "INFORMATION_ACCURACY_CONFIRMED", "value": False}, {"key": "APPLICATION_CODE", "value": ""}, {"key": "AREA_TYPE", "value": None}, {"key": "WINTERSTORAGEAREACHOICE_SET", "value": []}, { "key": "STORAGE_METHOD", "value": dict(WinterStorageMethod.choices)[ winter_storage_application.storage_method ], }, {"key": "TRAILER_REGISTRATION_NUMBER", "value": ""}, ], } ], }, winter_storage_applications_dict, ) test_case.assertDictEqual( { "key": "WINTER_STORAGE_LEASES", "children": [ { "key": "WINTERSTORAGELEASE", "children": [ {"key": "ID", "value": str(winter_storage_lease.id)}, {"key": "BOAT", "value": str(boat.id)}, { "key": "STATUS", "value": dict(LeaseStatus.choices)[ winter_storage_lease.status ], }, {"key": "ORDERS", "value": []}, {"key": "COMMENT", "value": winter_storage_lease.comment}, { "key": "PLACE", "value": { "key": "WINTERSTORAGEPLACE", "children": [ { "key": "NUMBER", "value": winter_storage_lease.place.number, }, { "key": "WINTER_STORAGE_SECTION", "value": { "key": "WINTERSTORAGESECTION", "children": [ { "key": "IDENTIFIER", "value": ( winter_storage_lease.place.winter_storage_section.identifier ), } ], }, }, ], }, }, {"key": "SECTION", "value": None}, {"key": "APPLICATION", "value": None}, { "key": "START_DATE", "value": winter_storage_lease.start_date.strftime( "%d-%m-%Y" ), }, { "key": "END_DATE", "value": winter_storage_lease.end_date.strftime("%d-%m-%Y"), }, {"key": "STICKER_NUMBER", "value": None}, {"key": "STICKER_POSTED", "value": None}, ], } ], }, winter_storage_leases_dict, )