def test_disable_microfrontend_for_basket_page_flag( self, microfrontend_enabled, payment_microfrontend_url, disable_microfrontend_flag_active, expected_result): """ Verify that the `disable_microfrontend_for_basket_page_flag` correctly disables the microfrontend url retrieval """ with override_flag(DISABLE_MICROFRONTEND_FOR_BASKET_PAGE_FLAG_NAME, active=disable_microfrontend_flag_active): self.site_configuration.enable_microfrontend_for_basket_page = microfrontend_enabled self.site_configuration.payment_microfrontend_url = payment_microfrontend_url self.assertEqual( get_payment_microfrontend_url_if_configured(self.request), expected_result)
def _redirect_to_payment_microfrontend_if_configured(self, request): microfrontend_url = get_payment_microfrontend_url_if_configured(request) if microfrontend_url: # For now, the enterprise consent form validation is communicated via # a URL parameter, which must be forwarded via this redirect. consent_failed_param_to_forward = request.GET.get(CONSENT_FAILED_PARAM) if consent_failed_param_to_forward: microfrontend_url = '{}?{}={}'.format( microfrontend_url, CONSENT_FAILED_PARAM, consent_failed_param_to_forward, ) redirect_response = HttpResponseRedirect(microfrontend_url) raise RedirectException(response=redirect_response)