shuup.testing package

Submodules

shuup.testing.browser_utils module

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/api/shuup.testing.rst, line 20)

autodoc: failed to import module ‘shuup.testing.browser_utils’; the following exception was raised: Traceback (most recent call last): File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/sphinx/ext/autodoc.py”, line 507, in import_object __import__(self.modname) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/testing/browser_utils.py”, line 8, in <module> from selenium.common.exceptions import ( ImportError: No module named ‘selenium’

shuup.testing.checkout_with_login_and_register_urls module

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/api/shuup.testing.rst, line 28)

autodoc: failed to import module ‘shuup.testing.checkout_with_login_and_register_urls’; the following exception was raised: Traceback (most recent call last): File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/sphinx/ext/autodoc.py”, line 507, in import_object __import__(self.modname) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/testing/checkout_with_login_and_register_urls.py”, line 19, in <module> url(r’^api/’, include(‘shuup.api.urls’)), File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/django/conf/urls/__init__.py”, line 33, in include urlconf_module = import_module(urlconf_module) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/importlib/__init__.py”, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/urls.py”, line 15, in <module> from .docs import SwaggerSchemaView File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/docs.py”, line 14, in <module> from rest_framework.compat import coreapi ImportError: cannot import name ‘coreapi’

shuup.testing.extend_classes module

class shuup.testing.extend_classes.DifferentProductOrderForm(request, context, product, language, **kwargs)[source]

Bases: shuup.front.forms.order_forms.ProductOrderForm

template_name = 'shuup_testing/different_order_form.jinja'
is_compatible()[source]

shuup.testing.factories module

class shuup.testing.factories.FuzzyBoolean(probability, **kwargs)[source]

Bases: factory.fuzzy.BaseFuzzyAttribute

fuzz()[source]
class shuup.testing.factories.UserFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

username = <factory.declarations.Sequence object>
email = <factory.declarations.Sequence object>
password = <factory.declarations.PostGenerationMethodCall object>
first_name = <factory.fuzzy.FuzzyText object>
last_name = <factory.fuzzy.FuzzyText object>
class shuup.testing.factories.CompanyFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

name = <factory.fuzzy.FuzzyText object>
tax_number = <factory.fuzzy.FuzzyText object>
email = <factory.declarations.Sequence object>
class shuup.testing.factories.ShopFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

slug = <factory.fuzzy.FuzzyText object>
name = <factory.fuzzy.FuzzyText object>
owner = <factory.declarations.SubFactory object>
class shuup.testing.factories.ProductTypeFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

identifier = <factory.declarations.Sequence object>
name = <factory.fuzzy.FuzzyText object>
class shuup.testing.factories.SalesUnitFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

name = <factory.fuzzy.FuzzyText object>
symbol = <factory.fuzzy.FuzzyText object>
class shuup.testing.factories.CategoryFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

identifier = <factory.declarations.Sequence object>
name = <factory.fuzzy.FuzzyText object>
status = <factory.fuzzy.FuzzyChoice object>
post = <factory.declarations.PostGeneration object>
class shuup.testing.factories.ShopProductFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

purchasable = <shuup.testing.factories.FuzzyBoolean object>
visibility = <factory.fuzzy.FuzzyChoice object>
default_price_value = <factory.fuzzy.FuzzyDecimal object>
class shuup.testing.factories.FuzzyName(prefix='', length=12, suffix='', chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', **kwargs)[source]

Bases: factory.fuzzy.FuzzyText

fuzz()[source]
class shuup.testing.factories.ProductFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

type = <factory.declarations.LazyAttribute object>
sku = <factory.fuzzy.FuzzyText object>
sales_unit = <factory.declarations.LazyAttribute object>
tax_class = <factory.declarations.LazyAttribute object>
profit_center = <factory.fuzzy.FuzzyInteger object>
cost_center = <factory.fuzzy.FuzzyInteger object>
name = <shuup.testing.factories.FuzzyName object>
post = <factory.declarations.PostGeneration object>
shuup.testing.factories.get_address(**overrides)[source]
shuup.testing.factories.default_by_identifier(model)[source]
shuup.testing.factories.get_default_attribute_set()[source]
shuup.testing.factories.get_default_product_type()[source]
shuup.testing.factories.get_default_manufacturer()[source]
shuup.testing.factories.get_tax(code, name, rate=None, amount=None)[source]
shuup.testing.factories.create_default_tax_rule(tax)[source]
shuup.testing.factories.get_default_tax()[source]
shuup.testing.factories.get_test_tax(rate)[source]
shuup.testing.factories.get_default_tax_class()[source]
shuup.testing.factories.get_currency(code, digits=2)[source]
shuup.testing.factories.get_default_currency()[source]
shuup.testing.factories.get_custom_payment_processor()[source]
shuup.testing.factories.get_payment_processor_with_checkout_phase()[source]
shuup.testing.factories.get_custom_carrier()[source]
shuup.testing.factories.get_default_payment_method()[source]
shuup.testing.factories.get_payment_method(shop=None, price=None, waive_at=None, name=None)[source]
shuup.testing.factories.get_default_shipping_method()[source]
shuup.testing.factories.get_shipping_method(shop=None, price=None, waive_at=None, name=None)[source]
shuup.testing.factories.get_default_customer_group()[source]
shuup.testing.factories.get_default_supplier()[source]
shuup.testing.factories.get_default_shop()[source]
shuup.testing.factories.get_shop(prices_include_tax, currency='EUR')[source]
shuup.testing.factories.get_default_product()[source]
shuup.testing.factories.get_default_shop_product()[source]
shuup.testing.factories.get_default_sales_unit()[source]
shuup.testing.factories.get_default_category()[source]
shuup.testing.factories.get_initial_order_status()[source]
shuup.testing.factories.get_completed_order_status()[source]
shuup.testing.factories.create_product(sku, shop=None, supplier=None, default_price=None, **attrs)[source]
shuup.testing.factories.create_package_product(sku, shop=None, supplier=None, default_price=None, children=4, **attrs)[source]
shuup.testing.factories.create_empty_order(prices_include_tax=False, shop=None)[source]
shuup.testing.factories.add_product_to_order(order, supplier, product, quantity, taxless_base_unit_price, tax_rate=0, pricing_context=None)[source]
shuup.testing.factories.create_order_with_product(product, supplier, quantity, taxless_base_unit_price, tax_rate=0, n_lines=1, shop=None)[source]
shuup.testing.factories.get_random_filer_image()[source]
shuup.testing.factories.get_faker(providers, locale=None)[source]
shuup.testing.factories.get_random_email(fake)[source]
shuup.testing.factories.create_random_address(fake=None, **values)[source]
shuup.testing.factories.create_random_person(locale=None, minimum_name_comp_len=0)[source]

Create a random PersonContact from the given locale (or a random one).

The minimum length for name components can be given, to work around possible issues with components expecting a long-enough string.

Parameters:
  • locale (str|None) – Locale name
  • minimum_name_comp_len (int) – Minimum name component length
Returns:

Person contact

Return type:

PersonContact

shuup.testing.factories.create_random_contact_group()[source]
shuup.testing.factories.create_random_company()[source]
shuup.testing.factories.create_random_order(customer=None, products=(), completion_probability=0, shop=None)[source]
shuup.testing.factories.create_random_product_attribute()[source]
shuup.testing.factories.get_all_seeing_key(user_or_contact)[source]
shuup.testing.factories.get_basket()[source]

shuup.testing.image_generator module

class shuup.testing.image_generator.BaseImageGenerator(image, palette, seed)[source]

Bases: object

Parameters:
  • image (PIL.Image.Image) – The image to draw on
  • palette – A list of RGB tuples
  • seed (int) – Random generator seed
generate()[source]
draw_circle(x, y, w, h, color)[source]
draw_rectangle(x, y, w, h, color)[source]
class shuup.testing.image_generator.RandomImageGenerator(image, palette, seed)[source]

Bases: shuup.testing.image_generator.BaseImageGenerator

Parameters:
  • image (PIL.Image.Image) – The image to draw on
  • palette – A list of RGB tuples
  • seed (int) – Random generator seed
generate()[source]
step()[source]
class shuup.testing.image_generator.ModernArtImageGenerator(image, palette, seed)[source]

Bases: shuup.testing.image_generator.BaseImageGenerator

Parameters:
  • image (PIL.Image.Image) – The image to draw on
  • palette – A list of RGB tuples
  • seed (int) – Random generator seed
generate()[source]
class shuup.testing.image_generator.RingImageGenerator(image, palette, seed)[source]

Bases: shuup.testing.image_generator.BaseImageGenerator

Parameters:
  • image (PIL.Image.Image) – The image to draw on
  • palette – A list of RGB tuples
  • seed (int) – Random generator seed
generate()[source]
shuup.testing.image_generator.generate_image(width, height, palette=None, seed=None, supersample=2)[source]

shuup.testing.mock_population module

class shuup.testing.mock_population.Populator[source]

Bases: object

populate()[source]
generate_pricing(product)[source]
populate_if_required()[source]
shuup.testing.mock_population.populate_if_required()[source]

shuup.testing.notify_script_templates module

class shuup.testing.notify_script_templates.DummyScriptTemplate(script_instance=None)[source]

Bases: shuup.notify.base.ScriptTemplate

Parameters:script_instance (shuup.notify.models.script.Script|None) – script instance to change or None
identifier = 'dummy_script_template'
name = 'A Dummy Script Template'
description = 'More Texts'
help_text = 'A good help here'
create_script(form=None)[source]
can_edit_script()[source]
update_script(form)[source]

shuup.testing.service_forms module

class shuup.testing.service_forms.PseudoPaymentProcessorForm(**kwargs)[source]

Bases: shuup.admin.forms._base.ShuupAdminForm

class Meta[source]

Bases: object

model

alias of PseudoPaymentProcessor

exclude = ['identifier']
PseudoPaymentProcessorForm.base_fields = OrderedDict([('enabled', <django.forms.fields.BooleanField object at 0x7fabc760d390>), ('logo', <filer.fields.image.AdminImageFormField object at 0x7fabc759e4a8>), ('bg_color', <django.forms.fields.CharField object at 0x7fabc750bc18>), ('fg_color', <django.forms.fields.CharField object at 0x7fabc750b7b8>), ('name', <django.forms.fields.CharField object at 0x7fabc8375dd8>)])
PseudoPaymentProcessorForm.declared_fields = OrderedDict([('name', <django.forms.fields.CharField object at 0x7fabc8375dd8>)])
PseudoPaymentProcessorForm.media
class shuup.testing.service_forms.PaymentWithCheckoutPhaseForm(**kwargs)[source]

Bases: shuup.admin.forms._base.ShuupAdminForm

class Meta[source]

Bases: object

model

alias of PaymentWithCheckoutPhase

exclude = ['identifier']
PaymentWithCheckoutPhaseForm.base_fields = OrderedDict([('enabled', <django.forms.fields.BooleanField object at 0x7fabc76aacf8>), ('logo', <filer.fields.image.AdminImageFormField object at 0x7fabcb903710>), ('rounding_quantize', <django.forms.fields.DecimalField object at 0x7fabc7c46240>), ('rounding_mode', <enumfields.forms.EnumChoiceField object at 0x7fabc76da978>), ('name', <django.forms.fields.CharField object at 0x7fabc76b8550>)])
PaymentWithCheckoutPhaseForm.declared_fields = OrderedDict([('name', <django.forms.fields.CharField object at 0x7fabc76b8550>)])
PaymentWithCheckoutPhaseForm.media
class shuup.testing.service_forms.CarrierWithCheckoutPhaseForm(**kwargs)[source]

Bases: shuup.admin.forms._base.ShuupAdminForm

class Meta[source]

Bases: object

model

alias of CarrierWithCheckoutPhase

exclude = ['identifier']
CarrierWithCheckoutPhaseForm.base_fields = OrderedDict([('enabled', <django.forms.fields.BooleanField object at 0x7fabc76da0f0>), ('logo', <filer.fields.image.AdminImageFormField object at 0x7fabc76da5c0>), ('name', <django.forms.fields.CharField object at 0x7fabc7bb50b8>)])
CarrierWithCheckoutPhaseForm.declared_fields = OrderedDict([('name', <django.forms.fields.CharField object at 0x7fabc7bb50b8>)])
CarrierWithCheckoutPhaseForm.media

shuup.testing.simple_checkout_phase module

class shuup.testing.simple_checkout_phase.TestPaymentCheckoutPhaseForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False)[source]

Bases: django.forms.forms.Form

base_fields = OrderedDict([('input_field', <django.forms.fields.BooleanField object at 0x7fabc7667a20>)])
declared_fields = OrderedDict([('input_field', <django.forms.fields.BooleanField object at 0x7fabc7667a20>)])
media
class shuup.testing.simple_checkout_phase.TestShipmentCheckoutPhaseForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False)[source]

Bases: django.forms.forms.Form

base_fields = OrderedDict([('input_field', <django.forms.fields.CharField object at 0x7fabc7667a58>)])
declared_fields = OrderedDict([('input_field', <django.forms.fields.CharField object at 0x7fabc7667a58>)])
media
class shuup.testing.simple_checkout_phase.TestMethodCheckoutPhase(checkout_process=None, horizontal_template=True, *args, **kwargs)[source]

Bases: shuup.front.checkout.CheckoutPhaseViewMixin, django.views.generic.edit.FormView

Initialize a checkout phase view.

Parameters:
  • checkout_process (shuup.front.checkout.CheckoutProcess|None) – The checkout process of this phase
  • horizontal_template (bool) – Set this to False if you want to use single page checkout
template_name = 'shuup_testing/simple_checkout_phase.jinja'
data_attribute = None
storage_identifier = None
get_initial()[source]
form_valid(form)[source]
is_valid()[source]
process()[source]
class shuup.testing.simple_checkout_phase.TestPaymentCheckoutPhase(checkout_process=None, horizontal_template=True, *args, **kwargs)[source]

Bases: shuup.testing.simple_checkout_phase.TestMethodCheckoutPhase

Initialize a checkout phase view.

Parameters:
  • checkout_process (shuup.front.checkout.CheckoutProcess|None) – The checkout process of this phase
  • horizontal_template (bool) – Set this to False if you want to use single page checkout
identifier = 'test_payment_phase'
title = 'Test Payment Phase'
form_class

alias of TestPaymentCheckoutPhaseForm

storage_identifier = 'payment_with_checkout_phase'
data_attribute = 'payment_data'
class shuup.testing.simple_checkout_phase.TestShipmentCheckoutPhase(checkout_process=None, horizontal_template=True, *args, **kwargs)[source]

Bases: shuup.testing.simple_checkout_phase.TestMethodCheckoutPhase

Initialize a checkout phase view.

Parameters:
  • checkout_process (shuup.front.checkout.CheckoutProcess|None) – The checkout process of this phase
  • horizontal_template (bool) – Set this to False if you want to use single page checkout
identifier = 'test_shipment_phase'
title = 'Test Shipment Phase'
form_class

alias of TestShipmentCheckoutPhaseForm

storage_identifier = 'shipment_with_checkout_phase'
data_attribute = 'shipping_data'
class shuup.testing.simple_checkout_phase.PaymentPhaseProvider[source]

Bases: shuup.front.checkout.BasicServiceCheckoutPhaseProvider

phase_class

alias of TestPaymentCheckoutPhase

service_provider_class

alias of PaymentWithCheckoutPhase

class shuup.testing.simple_checkout_phase.ShipmentPhaseProvider[source]

Bases: shuup.front.checkout.BasicServiceCheckoutPhaseProvider

phase_class

alias of TestShipmentCheckoutPhase

service_provider_class

alias of CarrierWithCheckoutPhase

shuup.testing.single_page_checkout_test_urls module

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/api/shuup.testing.rst, line 92)

autodoc: failed to import module ‘shuup.testing.single_page_checkout_test_urls’; the following exception was raised: Traceback (most recent call last): File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/sphinx/ext/autodoc.py”, line 507, in import_object __import__(self.modname) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/testing/single_page_checkout_test_urls.py”, line 19, in <module> url(r’^api/’, include(‘shuup.api.urls’)), File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/django/conf/urls/__init__.py”, line 33, in include urlconf_module = import_module(urlconf_module) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/importlib/__init__.py”, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/urls.py”, line 15, in <module> from .docs import SwaggerSchemaView File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/docs.py”, line 14, in <module> from rest_framework.compat import coreapi ImportError: cannot import name ‘coreapi’

shuup.testing.single_page_checkout_with_login_and_register_conf module

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/api/shuup.testing.rst, line 100)

autodoc: failed to import module ‘shuup.testing.single_page_checkout_with_login_and_register_conf’; the following exception was raised: Traceback (most recent call last): File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/sphinx/ext/autodoc.py”, line 507, in import_object __import__(self.modname) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/testing/single_page_checkout_with_login_and_register_conf.py”, line 34, in <module> url(r’^api/’, include(‘shuup.api.urls’)), File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/site-packages/django/conf/urls/__init__.py”, line 33, in include urlconf_module = import_module(urlconf_module) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/envs/v2.0.0/lib/python3.5/importlib/__init__.py”, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/urls.py”, line 15, in <module> from .docs import SwaggerSchemaView File “/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/doc/../shuup/api/docs.py”, line 14, in <module> from rest_framework.compat import coreapi ImportError: cannot import name ‘coreapi’

shuup.testing.soup_utils module

shuup.testing.soup_utils.extract_form_fields(soup)[source]

Turn a BeautifulSoup form in to a dict of fields and default values

shuup.testing.text_data module

shuup.testing.text_data.random_title(second_adj_chance=0.3, prefix='', suffix='')[source]

shuup.testing.utils module

shuup.testing.utils.apply_request_middleware(request, **attrs)[source]

Apply all the process_request capable middleware configured into the given request.

Parameters:
Returns:

The same request, massaged in-place.

Return type:

django.http.HttpRequest

shuup.testing.utils.apply_view_middleware(request)[source]

Apply all the process_view capable middleware configured into the given request.

The logic is roughly copied from django.core.handlers.base.BaseHandler.get_response

Parameters:request (django.http.HttpRequest) – The request to massage.
Returns:The same request, massaged in-place.
Return type:django.http.HttpRequest
shuup.testing.utils.apply_all_middleware(request, **attrs)[source]

Apply all the process_request and process_view capable middleware configured into the given request.

Parameters:
  • request (django.http.HttpRequest) – The request to massage.
  • attrs (dict) – Additional attributes to set to the request after massage.
Returns:

The same request, massaged in-place.

Return type:

django.http.HttpRequest

shuup.testing.utils.initialize_front_browser_test(browser, live_server)[source]
shuup.testing.utils.initialize_admin_browser_test(browser, live_server, settings, username='admin', password='password')[source]

Module contents

class shuup.testing.ShuupTestingAppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.testing'
verbose_name = 'Shuup Testing & Demo Utilities'
label = 'shuup_testing'
provides = {'xtheme': ['shuup.testing.themes:ShuupTestingTheme', 'shuup.testing.themes:ShuupTestingThemeWithCustomBase'], 'service_provider_admin_form': ['shuup.testing.service_forms:PseudoPaymentProcessorForm', 'shuup.testing.service_forms:PaymentWithCheckoutPhaseForm', 'shuup.testing.service_forms:CarrierWithCheckoutPhaseForm'], 'admin_contact_toolbar_action_item': ['shuup.testing.admin_module.toolbar:MockContactToolbarActionItem'], 'admin_contact_edit_toolbar_button': ['shuup.testing.admin_module.toolbar:MockContactToolbarButton'], 'admin_module': ['shuup.testing.admin_module:TestingAdminModule'], 'admin_contact_section': ['shuup.testing.admin_module.sections:MockContactSection'], 'admin_contact_toolbar_button': ['shuup.testing.admin_module.toolbar:MockContactToolbarButton'], 'front_service_checkout_phase_provider': ['shuup.testing.simple_checkout_phase.PaymentPhaseProvider', 'shuup.testing.simple_checkout_phase.ShipmentPhaseProvider'], 'admin_product_toolbar_action_item': ['shuup.testing.admin_module.toolbar:MockProductToolbarActionItem']}