def test_shop_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.shops.views:ShopWizardPane" ] shop = Shop.objects.create() get_currency("USD") assert not shop.contact_address assert not TaxClass.objects.exists() fields = _extract_fields(rf, admin_user) fields["shop-logo"] = "" # Correct init value for this is not None, but empty string request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) # fields are missing assert response.status_code == 400 fields["shop-public_name__fi"] = "test shop" fields["shop-currency"] = "USD" fields["address-name"] = "TEST" fields["address-city"] = "TEST" fields["address-region_code"] = "CA" fields["address-street"] = "test" fields["address-country"] = "US" request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 shop.refresh_from_db() shop.set_current_language("fi") assert shop.name == "test shop" assert shop.public_name == "test shop" assert shop.logo is None assert shop.contact_address assert shop.currency == "USD" assert TaxClass.objects.exists() assert_redirect_to_dashboard(rf)
def test_shop_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.shops.views:ShopWizardPane" ] shop = get_default_shop() assert not shop.contact_address assert not TaxClass.objects.exists() fields = _extract_fields(rf, admin_user) request = rf.post("/", data=fields) response = WizardView.as_view()(request) # fields are missing assert response.status_code == 400 fields["shop-currency"] = "USD" fields["address-region_code"] = "CA" fields["address-street"] = "test" fields["address-country"] = "US" request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert response.status_code == 200 shop.refresh_from_db() assert shop.contact_address assert shop.currency == "USD" assert TaxClass.objects.exists() assert_redirect_to_dashboard(rf)
def test_sample_data_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.testing.modules.sample_data.views.SampleObjectsWizardPane" ] shop = get_default_shop() get_default_tax_class() data = { 'pane_id': 'sample', 'sample-business_segment': 'default', 'sample-categories': True, 'sample-products': True, 'sample-carousel': True } request = apply_request_middleware(rf.post("/", data=data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Product.objects.count() == len( BUSINESS_SEGMENTS["default"]["products"]) anon_contact = AnonymousContact() supplier = get_default_supplier() # check for the injected plugin using the carousel assert Carousel.objects.count() == 1 carousel = Carousel.objects.first() assert Slide.objects.count() == len( BUSINESS_SEGMENTS["default"]["carousel"]["slides"]) svc = SavedViewConfig.objects.first() assert svc.view_name == "IndexView" layout = svc.get_layout_data("front_content") assert layout['rows'][0]['cells'][0]['config']['carousel'] == carousel.pk assert layout['rows'][0]['cells'][0]['plugin'] == CarouselPlugin.identifier for product in Product.objects.all(): # all products must be orderable and have images assert product.get_shop_instance(shop).is_orderable( supplier=supplier, customer=anon_contact, quantity=1) assert product.primary_image is not None assert Category.objects.count() == len( BUSINESS_SEGMENTS["default"]["categories"]) request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")
def get_urls(): urls = [] urls.extend(get_module_urls()) urls.extend([ admin_url(r'^$', DashboardView.as_view(), name='dashboard', permissions=()), admin_url(r'^home/$', HomeView.as_view(), name='home', permissions=()), admin_url(r'^wizard/$', WizardView.as_view(), name='wizard', permissions=()), admin_url(r'^tour/$', TourView.as_view(), name='tour', permissions=()), admin_url(r'^search/$', SearchView.as_view(), name='search', permissions=()), admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select', permissions=()), admin_url(r'^edit/$', EditObjectView.as_view(), name='edit', permissions=()), admin_url(r'^menu/$', MenuView.as_view(), name='menu', permissions=()), admin_url(r'^toggle-menu/$', MenuToggleView.as_view(), name='menu_toggle', permissions=()), admin_url( r'^login/$', login, kwargs={"template_name": "shuup/admin/auth/login.jinja"}, name='login', require_authentication=False, permissions=() ), admin_url( r'^logout/$', auth_views.logout, kwargs={"template_name": "shuup/admin/auth/logout.jinja"}, name='logout', require_authentication=False, permissions=() ), admin_url( r'^recover-password/(?P<uidb64>.+)/(?P<token>.+)/$', ResetPasswordView, name='recover_password', require_authentication=False, permissions=() ), admin_url( r'^request-password/$', RequestPasswordView, name='request_password', require_authentication=False, permissions=() ), admin_url( r'^set-language/$', csrf_exempt(set_language), name="set-language", permissions=() ), ]) for u in urls: # pragma: no cover if not isinstance(u, AdminRegexURLPattern): warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u) # Add Django javascript catalog url urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog')) return tuple(urls)
def get_urls(): urls = [] urls.extend(get_module_urls()) urls.extend([ admin_url(r'^$', DashboardView.as_view(), name='dashboard'), admin_url(r'^home/$', HomeView.as_view(), name='home'), admin_url(r'^wizard/$', WizardView.as_view(), name='wizard'), admin_url(r'^tour/$', TourView.as_view(), name='tour'), admin_url(r'^search/$', SearchView.as_view(), name='search'), admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select'), admin_url(r'^menu/$', MenuView.as_view(), name='menu'), admin_url(r'^login/$', login, kwargs={"template_name": "shuup/admin/auth/login.jinja"}, name='login', require_authentication=False), admin_url(r'^logout/$', auth_views.logout, kwargs={"template_name": "shuup/admin/auth/logout.jinja"}, name='logout', require_authentication=False), admin_url(r'^set-language/$', csrf_exempt(set_language), name="set-language"), ]) for u in urls: # pragma: no cover if not isinstance(u, AdminRegexURLPattern): warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u) # Add Django javascript catalog url urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog')) return tuple(urls)
def test_sample_data_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.testing.modules.sample_data.views.SampleObjectsWizardPane" ] shop = get_default_shop() get_default_tax_class() data = { 'pane_id': 'sample', 'sample-business_segment': 'default', 'sample-categories': True, 'sample-products': True, 'sample-carousel': True } request = apply_request_middleware(rf.post("/", data=data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Product.objects.count() == len(BUSINESS_SEGMENTS["default"]["products"]) anon_contact = AnonymousContact() supplier = get_default_supplier() # check for the injected plugin using the carousel assert Carousel.objects.count() == 1 carousel = Carousel.objects.first() assert Slide.objects.count() == len(BUSINESS_SEGMENTS["default"]["carousel"]["slides"]) svc = SavedViewConfig.objects.first() assert svc.view_name == "IndexView" layout = svc.get_layout_data("front_content") assert layout['rows'][0]['cells'][0]['config']['carousel'] == carousel.pk assert layout['rows'][0]['cells'][0]['plugin'] == CarouselPlugin.identifier for product in Product.objects.all(): # all products must be orderable and have images assert product.get_shop_instance(shop).is_orderable(supplier=supplier, customer=anon_contact, quantity=1) assert product.primary_image is not None assert Category.objects.count() == len(BUSINESS_SEGMENTS["default"]["categories"]) request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")
def test_telemetry_wizard_pane(rf, admin_user): with override_settings(SHUUP_SETUP_WIZARD_PANE_SPEC=[ "shuup.admin.modules.system.views.TelemetryWizardPane" ]): shop = get_default_shop() request = apply_request_middleware(rf.get("/"), user=admin_user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 200 assert not is_opt_out() soup = BeautifulSoup(response.render().content) h2_elements = soup.find_all("h2") expected_h2_element_titles = [ "Telemetry", "About Shuup Telemetry", "Telemetry Data", "Opt-in / opt-out", "Last Telemetry" ] assert len(h2_elements) == len(expected_h2_element_titles) for h2_element in h2_elements: assert h2_element.text.strip() in expected_h2_element_titles # By default installation should be opted in assert "Thank you for your valuable contribution." in soup.text # Opt out fields = _extract_fields(rf, admin_user) fields["telemetry-opt_in_telemetry"] = False request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 # Post seems to cause JSON response assert is_opt_out() # So let's re-get the telemetry page request = apply_request_middleware(rf.get("/"), user=admin_user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 200 soup = BeautifulSoup(response.render().content) # Installation should be now opted out assert "Thank you for your valuable contribution." not in soup.text assert "You are currently opted out of Shuup telemetry." in soup.text
def test_wizard_pane(rf, admin_user, settings): with override_settings(SHUUP_SETUP_WIZARD_PANE_SPEC=["shuup.admin.modules.service_providers.views.PaymentWizardPane"]): factories.get_default_shop() factories.get_default_tax_class() request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200
def test_wizard_redirect(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [] shop = get_default_shop() shop.maintenance_mode = True shop.save() request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:home")
def test_wizard_pane(rf, admin_user, settings): with override_settings( SHUUP_SETUP_WIZARD_PANE_SPEC=["shuup.admin.modules.service_providers.views.PaymentWizardPane"]): factories.get_default_shop() factories.get_default_tax_class() request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200
def test_telemetry_wizard_pane(rf, admin_user): with override_settings(SHUUP_SETUP_WIZARD_PANE_SPEC=["shuup.admin.modules.system.views.TelemetryWizardPane"]): shop = get_default_shop() request = apply_request_middleware(rf.get("/"), user=admin_user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 200 assert not is_opt_out() soup = BeautifulSoup(response.render().content) h2_elements = soup.find_all("h2") expected_h2_element_titles = [ "Telemetry", "About Shuup Telemetry", "Telemetry Data", "Opt-in / opt-out", "Last Telemetry" ] assert len(h2_elements) == len(expected_h2_element_titles) for h2_element in h2_elements: assert h2_element.text.strip() in expected_h2_element_titles # By default installation should be opted in assert "Thank you for your valuable contribution." in soup.text # Opt out fields = _extract_fields(rf, admin_user) fields["telemetry-opt_in_telemetry"] = False request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 # Post seems to cause JSON response assert is_opt_out() # So let's re-get the telemetry page request = apply_request_middleware(rf.get("/"), user=admin_user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 200 soup = BeautifulSoup(response.render().content) # Installation should be now opted out assert "Thank you for your valuable contribution." not in soup.text assert "You are currently opted out of Shuup telemetry." in soup.text
def test_languages_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.shops.views:ShopLanguagesWizardPane" ] shop = get_default_shop() configuration.set(shop, "languages", None) assert not configuration.get(shop, "languages", None) fields = _extract_fields(rf, admin_user) fields["shop_languages-languages"] = [] request = rf.post("/", data=fields) response = WizardView.as_view()(request) # fields are missing assert response.status_code == 400 fields["shop_languages-languages"] = ["en", "fi"] request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert response.status_code == 200 assert len(configuration.get(shop, "languages", None)) == 2
def test_xtheme_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.xtheme.admin_module.views.ThemeWizardPane" ] with override_current_theme_class(): with override_provides("xtheme", ["shuup_tests.xtheme.utils:FauxTheme"]): get_default_shop() assert get_current_theme() == None fields = _extract_fields(rf, admin_user) fields["theme-activate"] = FauxTheme.identifier request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert isinstance(get_current_theme(), FauxTheme) assert_redirect_to_dashboard(rf)
def test_xtheme_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.xtheme.admin_module.views.ThemeWizardPane" ] with override_current_theme_class(): with override_provides("xtheme", [ "shuup_tests.xtheme.utils:FauxTheme" ]): get_default_shop() assert get_current_theme() == None fields = _extract_fields(rf, admin_user) fields["theme-activate"] = FauxTheme.identifier request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert isinstance(get_current_theme(), FauxTheme) assert_redirect_to_dashboard(rf)
def test_shipping_method_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = ["shuup.admin.modules.service_providers.views.CarrierWizardPane"] shop = get_default_shop() get_default_tax_class() fields = _extract_fields(rf, admin_user) fields["shipping_method_base-providers"] = "manual_shipping" fields["manual_shipping-service_name"] = "test" request = apply_request_middleware(rf.post("/", data=fields), user=admin_user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 200 assert ServiceProvider.objects.count() == 1 assert CustomCarrier.objects.count() == 1 assert CustomCarrier.objects.first().name == "Manual" assert ShippingMethod.objects.count() == 1 assert ShippingMethod.objects.first().name == "test" assert_redirect_to_dashboard(rf, admin_user, shop)
def test_payment_method_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.service_providers.views.PaymentWizardPane" ] shop = get_default_shop() get_default_tax_class() fields = _extract_fields(rf, admin_user) fields["payment_method_base-providers"] = "manual_payment" fields["manual_payment-service_name"] = "test" request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert response.status_code == 200 assert ServiceProvider.objects.count() == 1 assert CustomPaymentProcessor.objects.count() == 1 assert CustomPaymentProcessor.objects.first().name == "Manual" assert PaymentMethod.objects.count() == 1 assert PaymentMethod.objects.first().name == "test" assert_redirect_to_dashboard(rf)
def test_payment_method_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.service_providers.views.PaymentWizardPane" ] shop = get_default_shop() get_default_tax_class() fields = _extract_fields(rf, admin_user) fields["payment_method_base-providers"] = "manual_payment" fields["manual_payment-service_name"] = "test" request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert ServiceProvider.objects.count() == 1 assert CustomPaymentProcessor.objects.count() == 1 assert CustomPaymentProcessor.objects.first().name == "Manual" assert PaymentMethod.objects.count() == 1 assert PaymentMethod.objects.first().name == "test" assert_redirect_to_dashboard(rf, admin_user, shop)
def test_shipping_method_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.service_providers.views.CarrierWizardPane" ] shop = get_default_shop() get_default_tax_class() fields = _extract_fields(rf, admin_user) fields["shipping_method_base-providers"] = "manual_shipping" fields["manual_shipping-service_name"] = "test" request = rf.post("/", data=fields) response = WizardView.as_view()(request) assert response.status_code == 200 assert ServiceProvider.objects.count() == 1 assert CustomCarrier.objects.count() == 1 assert CustomCarrier.objects.first().name == "Manual" assert ShippingMethod.objects.count() == 1 assert ShippingMethod.objects.first().name == "test" assert_redirect_to_dashboard(rf)
def get_urls(): urls = [] urls.extend(get_module_urls()) urls.extend([ admin_url(r'^$', DashboardView.as_view(), name='dashboard'), admin_url(r'^home/$', HomeView.as_view(), name='home'), admin_url(r'^wizard/$', WizardView.as_view(), name='wizard'), admin_url(r'^tour/$', TourView.as_view(), name='tour'), admin_url(r'^search/$', SearchView.as_view(), name='search'), admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select'), admin_url(r'^menu/$', MenuView.as_view(), name='menu'), admin_url( r'^login/$', login, kwargs={"template_name": "shuup/admin/auth/login.jinja"}, name='login', require_authentication=False ), admin_url( r'^logout/$', auth_views.logout, kwargs={"template_name": "shuup/admin/auth/logout.jinja"}, name='logout', require_authentication=False ), admin_url( r'^set-language/$', csrf_exempt(set_language), name="set-language" ), ]) for u in urls: # pragma: no cover if not isinstance(u, AdminRegexURLPattern): warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u) # Add Django javascript catalog url urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog')) return tuple(urls)
def get_urls(): urls = [] urls.extend(get_module_urls()) urls.extend( [ admin_url(r"^$", DashboardView.as_view(), name="dashboard"), admin_url(r"^home/$", HomeView.as_view(), name="home"), admin_url(r"^wizard/$", WizardView.as_view(), name="wizard"), admin_url(r"^tour/$", TourView.as_view(), name="tour"), admin_url(r"^search/$", SearchView.as_view(), name="search"), admin_url(r"^select/$", MultiselectAjaxView.as_view(), name="select"), admin_url(r"^menu/$", MenuView.as_view(), name="menu"), admin_url( r"^login/$", login, kwargs={"template_name": "shuup/admin/auth/login.jinja"}, name="login", require_authentication=False, ), admin_url( r"^logout/$", auth_views.logout, kwargs={"template_name": "shuup/admin/auth/logout.jinja"}, name="logout", require_authentication=False, ), admin_url(r"^set-language/$", csrf_exempt(set_language), name="set-language"), ] ) for u in urls: # pragma: no cover if not isinstance(u, AdminRegexURLPattern): warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u) # Add Django javascript catalog url urls.append(url(r"^i18n.js$", javascript_catalog_all, name="js-catalog")) return tuple(urls)
def test_xtheme_wizard_pane(rf, admin_user): with override_settings( SHUUP_SETUP_WIZARD_PANE_SPEC=["shuup.xtheme.admin_module.views.ThemeWizardPane"], CACHES={ "default": { "BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": "test_simple_set_and_get_with_shop", } }, ): cache.init_cache() shop = get_default_shop() with override_provides("xtheme", ["shuup_tests.xtheme.utils:FauxTheme"]): from shuup_tests.xtheme.utils import FauxTheme assert get_current_theme(shop) is None fields = _extract_fields(rf, admin_user) fields["theme-activate"] = FauxTheme.identifier request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert isinstance(get_current_theme(shop), FauxTheme) assert_redirect_to_dashboard(rf, admin_user, shop)
def test_xtheme_wizard_pane(rf, admin_user): with override_settings( SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.xtheme.admin_module.views.ThemeWizardPane" ], CACHES={ 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'test_simple_set_and_get_with_shop', } } ): cache.init_cache() shop = get_default_shop() with override_provides("xtheme", ["shuup_tests.xtheme.utils:FauxTheme"]): from shuup_tests.xtheme.utils import FauxTheme assert get_current_theme(shop) is None fields = _extract_fields(rf, admin_user) fields["theme-activate"] = FauxTheme.identifier request = apply_request_middleware(rf.post("/", data=fields), user=admin_user) response = WizardView.as_view()(request) assert isinstance(get_current_theme(shop), FauxTheme) assert_redirect_to_dashboard(rf, admin_user, shop)
def test_content_wizard_pane2(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.content.views.ContentWizardPane" ] shop = get_default_shop() settings.INSTALLED_APPS.remove("shuup.simple_cms") settings.INSTALLED_APPS.remove("shuup.xtheme") settings.INSTALLED_APPS.remove("shuup.notify") # no pane, because ContentWizardPane is invalid (no necessary app installed) assert wizard.load_setup_wizard_panes(shop) == [] assert wizard.load_setup_wizard_panes(shop, visible_only=False) == [] pane_data = { 'pane_id': 'content', 'content-privacy_policy': True, 'content-terms_conditions': True, 'content-refund_policy': True, 'content-about_us': True, 'content-configure_footer': True, 'behaviors-order_confirm_notification': True } request = apply_request_middleware(rf.get("/"), skip_session=True) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"].startswith(reverse("shuup:login")) # add the simple cms - create only the pages and footer settings.INSTALLED_APPS.append("shuup.simple_cms") assert len(wizard.load_setup_wizard_panes(shop, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 settings.INSTALLED_APPS.remove("shuup.simple_cms") Page.objects.all().delete() # add the xtheme - create the footer settings.INSTALLED_APPS.append("shuup.xtheme") assert len(wizard.load_setup_wizard_panes(shop, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 0 settings.INSTALLED_APPS.remove("shuup.xtheme") SavedViewConfig.objects.all().delete() # add the notify - create only the notification settings.INSTALLED_APPS.append("shuup.notify") assert len(wizard.load_setup_wizard_panes(shop, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 1 settings.INSTALLED_APPS.remove("shuup.notify") Script.objects.all().delete() settings.INSTALLED_APPS.append("shuup.simple_cms") settings.INSTALLED_APPS.append("shuup.xtheme") settings.INSTALLED_APPS.append("shuup.notify")
def test_content_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.testing.modules.content.views.ContentWizardPane" ] shop = get_default_shop() pane_data = { 'pane_id': 'content', 'content-privacy_policy': False, 'content-terms_conditions': False, 'content-refund_policy': False, 'content-about_us': False, 'content-configure_footer': False, 'behaviors-order_confirm_notification': False } # all false, does not create anything request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create privacy policy pane_data['content-privacy_policy'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 1 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create terms pane_data['content-terms_conditions'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 2 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create refund pane_data['content-refund_policy'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 3 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create about_us pane_data['content-about_us'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create footer pane_data['content-configure_footer'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 0 # create order_confirm_notification pane_data['behaviors-order_confirm_notification'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 1 request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")
def assert_redirect_to_dashboard(rf, user, shop): request = apply_request_middleware(rf.get("/"), user=user, shop=shop) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")
def _extract_fields(rf, user): request = apply_request_middleware(rf.get("/"), user=user) response = WizardView.as_view()(request) response.render() soup = BeautifulSoup(response.content) return extract_form_fields(soup.find("form"))
def test_content_wizard_pane2(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.testing.modules.content.views.ContentWizardPane" ] shop = get_default_shop() request = apply_request_middleware(rf.get("/"), user=admin_user) settings.INSTALLED_APPS.remove("shuup.simple_cms") settings.INSTALLED_APPS.remove("shuup.xtheme") settings.INSTALLED_APPS.remove("shuup.notify") # no pane, because ContentWizardPane is invalid (no necessary app installed) assert wizard.load_setup_wizard_panes(shop, request) == [] assert wizard.load_setup_wizard_panes(shop, request, visible_only=False) == [] pane_data = { 'pane_id': 'content', 'content-privacy_policy': True, 'content-terms_conditions': True, 'content-refund_policy': True, 'content-about_us': True, 'content-configure_footer': True, 'behaviors-order_confirm_notification': True } request = apply_request_middleware(rf.get("/"), skip_session=True) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"].startswith(reverse("shuup:login")) # add the simple cms - create only the pages and footer request = apply_request_middleware(rf.get("/"), user=admin_user, skip_session=True) settings.INSTALLED_APPS.append("shuup.simple_cms") assert len(wizard.load_setup_wizard_panes(shop, request, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 settings.INSTALLED_APPS.remove("shuup.simple_cms") Page.objects.all().delete() # add the xtheme - create the footer settings.INSTALLED_APPS.append("shuup.xtheme") assert len(wizard.load_setup_wizard_panes(shop, request, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 0 settings.INSTALLED_APPS.remove("shuup.xtheme") SavedViewConfig.objects.all().delete() # add the notify - create only the notification settings.INSTALLED_APPS.append("shuup.notify") assert len(wizard.load_setup_wizard_panes(shop, request, visible_only=False)) == 1 request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 1 settings.INSTALLED_APPS.remove("shuup.notify") Script.objects.all().delete() settings.INSTALLED_APPS.append("shuup.simple_cms") settings.INSTALLED_APPS.append("shuup.xtheme") settings.INSTALLED_APPS.append("shuup.notify")
def get_urls(): urls = [] urls.extend(get_module_urls()) urls.extend([ admin_url(r"^$", DashboardView.as_view(), name="dashboard", permissions=()), admin_url(r"^home/$", HomeView.as_view(), name="home", permissions=()), admin_url(r"^wizard/$", WizardView.as_view(), name="wizard", permissions=()), admin_url(r"^tour/$", TourView.as_view(), name="tour", permissions=()), admin_url(r"^search/$", SearchView.as_view(), name="search", permissions=()), admin_url(r"^select/$", MultiselectAjaxView.as_view(), name="select", permissions=()), admin_url(r"^edit/$", EditObjectView.as_view(), name="edit", permissions=()), admin_url(r"^menu/$", MenuView.as_view(), name="menu", permissions=()), admin_url(r"^toggle-menu/$", MenuToggleView.as_view(), name="menu_toggle", permissions=()), admin_url( r"^stop-impersonating-staff/$", stop_impersonating_staff, name="stop-impersonating-staff", permissions=(), ), admin_url( r"^login/$", login, kwargs={"template_name": "shuup/admin/auth/login.jinja"}, name="login", require_authentication=False, permissions=(), ), admin_url(r"^logout/$", LogoutView, name="logout", require_authentication=False, permissions=()), admin_url( r"^recover-password/(?P<uidb64>.+)/(?P<token>.+)/$", ResetPasswordView, name="recover_password", require_authentication=False, permissions=(), ), admin_url( r"^request-password/$", RequestPasswordView, name="request_password", require_authentication=False, permissions=(), ), admin_url(r"^set-language/$", csrf_exempt(set_language), name="set-language", permissions=()), ]) for u in urls: # pragma: no cover if not isinstance(u, AdminRegexURLPattern): warnings.warn( "Warning! Admin URL %r is not an `AdminRegexURLPattern`." % u) # Add Django javascript catalog url urls.append(url(r"^i18n.js$", javascript_catalog_all, name="js-catalog")) return tuple(urls)
def test_content_wizard_pane(rf, admin_user, settings): settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [ "shuup.admin.modules.content.views.ContentWizardPane" ] shop = get_default_shop() pane_data = { 'pane_id': 'content', 'content-privacy_policy': False, 'content-terms_conditions': False, 'content-refund_policy': False, 'content-about_us': False, 'content-configure_footer': False, 'behaviors-order_confirm_notification': False } # all false, does not create anything request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 0 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create privacy policy pane_data['content-privacy_policy'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 1 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create terms pane_data['content-terms_conditions'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 2 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create refund pane_data['content-refund_policy'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 3 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create about_us pane_data['content-about_us'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 0 assert Script.objects.count() == 0 # create footer pane_data['content-configure_footer'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 0 # create order_confirm_notification pane_data['behaviors-order_confirm_notification'] = True request = apply_request_middleware(rf.post("/", data=pane_data), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 200 assert Page.objects.count() == 4 assert SavedViewConfig.objects.count() == 1 assert Script.objects.count() == 1 request = apply_request_middleware(rf.get("/"), user=admin_user) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")
def assert_redirect_to_dashboard(rf): request = apply_request_middleware(rf.get("/")) response = WizardView.as_view()(request) assert response.status_code == 302 assert response["Location"] == reverse("shuup_admin:dashboard")