def test_storage_on_ice(customer_profile, region, business_unit, internal_order): harbor = HarborFactory(region=region) product = AdditionalProductFactory() assert (get_talpa_product_id( product.id, harbor, True ) == f"340100_{business_unit}_{internal_order}_ _292014_44_{product.id}")
def test_winter_storage_product(customer_profile, region, business_unit, internal_order): area = WinterStorageAreaFactory(region=region) product = WinterStorageProductFactory(winter_storage_area=area) assert (get_talpa_product_id( product.id, area ) == f"340100_{business_unit}_{internal_order}_ _292014_44_{product.id}")
def test_berth_product(customer_profile, region, business_unit, internal_order): harbor = HarborFactory(region=region) product = BerthProductFactory() assert (get_talpa_product_id( product.id, harbor ) == f"340100_{business_unit}_{internal_order}_ _292015_44_{product.id}")
def test_payload_additional_product_order(payment_provider, additional_product, storage_on_ice, berth_lease_without_product): if storage_on_ice: additional_product.service = ProductServiceType.STORAGE_ON_ICE else: additional_product.service = random.choice( list( filter( lambda x: x != ProductServiceType.STORAGE_ON_ICE, ProductServiceType.values, ))) additional_product.tax_percentage = Decimal("24.00") additional_product.save() OrderFactory( price=Decimal("0.00"), tax_percentage=Decimal("24.00"), product=None, lease=berth_lease_without_product, status=OrderStatus.PAID, ) berth_lease_without_product.status = LeaseStatus.PAID berth_lease_without_product.save() additional_product_order = OrderFactory( order_type=OrderType.ADDITIONAL_PRODUCT_ORDER, lease=berth_lease_without_product, product=None, price=Decimal("0.00"), tax_percentage=Decimal("0.00"), ) OrderLineFactory( order=additional_product_order, product=additional_product, price=Decimal("15.00"), ) payload = {} payment_provider.payload_add_products(payload, additional_product_order, "fi") assert payload["amount"] > 0 assert len(payload["products"]) == 1 product = payload["products"][0] assert product["id"] == get_talpa_product_id( additional_product.id, area=berth_lease_without_product.berth.pier.harbor, is_storage_on_ice=storage_on_ice, ) assert product["title"] is not None assert product["price"] > 0 assert product["pretax_price"] > 0 assert product["tax"] > 0 assert product["count"] == 1
def test_initiate_refund_no_order_email(provider_base_config: dict, order: Order): """Test the request creator constructs the payload base and returns a url that contains a token""" request = RequestFactory().request() order.status = OrderStatus.PAID order.email = None order.lease.status = LeaseStatus.PAID order.lease.save() order.save() OrderToken.objects.create( order=order, token="12345", valid_until=now() - relativedelta(days=7) ) if hasattr(order.product, "price_for_tier"): place_price = order.product.price_for_tier(order.lease.berth.pier.price_tier) area = order.lease.berth.pier.harbor else: # Winter products are priced per m2 place_price = rounded( order.product.price_value * order.lease.place.place_type.width * order.lease.place.place_type.length, round_to_nearest=1, ) area = order.lease.place.winter_storage_section.area products = [ { "id": get_talpa_product_id(order.product.id, area, False), "product_id": 1123, "title": order.product.name, "count": 1, "pretax_price": price_as_fractional_int( convert_aftertax_to_pretax(place_price, order.product.tax_percentage) ), "tax": int(order.product.tax_percentage), "price": price_as_fractional_int(place_price), "type": 1, } ] payment_provider = create_bambora_provider(provider_base_config, request) with mock.patch( "payments.providers.bambora_payform.requests.post", side_effect=mocked_refund_response_create, ), mock.patch( "payments.providers.bambora_payform.BamboraPayformProvider.get_payment_details", side_effect=mocked_refund_payment_details(products=products), ): refund = payment_provider.initiate_refund(order) assert refund.refund_id == "123456"