shoop.testing package

Submodules

shoop.testing.factories module

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

Bases: factory.fuzzy.BaseFuzzyAttribute

fuzz()[source]
class shoop.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 shoop.testing.factories.CompanyFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

name = <factory.fuzzy.FuzzyText object>
vat_id = <factory.fuzzy.FuzzyText object>
email = <factory.declarations.Sequence object>
class shoop.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 shoop.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 shoop.testing.factories.SalesUnitFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

name = <factory.fuzzy.FuzzyText object>
short_name = <factory.fuzzy.FuzzyText object>
class shoop.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 shoop.testing.factories.ShopProductFactory[source]

Bases: factory.django.DjangoModelFactory

Would be called if trying to instantiate the class.

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

Bases: factory.fuzzy.FuzzyText

fuzz()[source]
class shoop.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 = <shoop.testing.factories.FuzzyName object>
post = <factory.declarations.PostGeneration object>
shoop.testing.factories.get_address(**overrides)[source]
shoop.testing.factories.default_by_identifier(model)[source]
shoop.testing.factories.get_default_attribute_set()[source]
shoop.testing.factories.get_default_product_type()[source]
shoop.testing.factories.get_tax(code, name, rate=None, amount=None)[source]
shoop.testing.factories.create_default_tax_rule(tax)[source]
shoop.testing.factories.get_default_tax()[source]
shoop.testing.factories.get_test_tax(rate)[source]
shoop.testing.factories.get_default_tax_class()[source]
shoop.testing.factories.get_custom_payment_processor()[source]
shoop.testing.factories.get_custom_carrier()[source]
shoop.testing.factories.get_default_payment_method()[source]
shoop.testing.factories.get_payment_method(shop=None, price=None, waive_at=None, name=None)[source]
shoop.testing.factories.get_default_shipping_method()[source]
shoop.testing.factories.get_shipping_method(shop=None, price=None, waive_at=None, name=None)[source]
shoop.testing.factories.get_default_customer_group()[source]
shoop.testing.factories.get_default_supplier()[source]
shoop.testing.factories.get_default_shop()[source]
shoop.testing.factories.get_shop(prices_include_tax, currency='EUR')[source]
shoop.testing.factories.get_default_product()[source]
shoop.testing.factories.get_default_shop_product()[source]
shoop.testing.factories.get_default_sales_unit()[source]
shoop.testing.factories.get_default_category()[source]
shoop.testing.factories.get_initial_order_status()[source]
shoop.testing.factories.get_completed_order_status()[source]
shoop.testing.factories.create_product(sku, shop=None, supplier=None, default_price=None, **attrs)[source]
shoop.testing.factories.create_empty_order(prices_include_tax=False, shop=None)[source]
shoop.testing.factories.add_product_to_order(order, supplier, product, quantity, taxless_base_unit_price, tax_rate=0, pricing_context=None)[source]
shoop.testing.factories.create_order_with_product(product, supplier, quantity, taxless_base_unit_price, tax_rate=0, n_lines=1, shop=None)[source]
shoop.testing.factories.get_random_filer_image()[source]
shoop.testing.factories.get_faker(providers, locale=None)[source]
shoop.testing.factories.create_random_address(fake=None, **values)[source]
shoop.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

shoop.testing.factories.create_random_company()[source]
shoop.testing.factories.create_random_order(customer=None, products=(), completion_probability=0, shop=None)[source]

shoop.testing.image_generator module

class shoop.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 shoop.testing.image_generator.RandomImageGenerator(image, palette, seed)[source]

Bases: shoop.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 shoop.testing.image_generator.ModernArtImageGenerator(image, palette, seed)[source]

Bases: shoop.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 shoop.testing.image_generator.RingImageGenerator(image, palette, seed)[source]

Bases: shoop.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]
shoop.testing.image_generator.generate_image(width, height, palette=None, seed=None, supersample=2)[source]

shoop.testing.mock_population module

class shoop.testing.mock_population.Populator[source]

Bases: object

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

shoop.testing.service_forms module

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

Bases: shoop.admin.forms._base.ShoopAdminForm

class Meta[source]

Bases: object

model

alias of PseudoPaymentProcessor

exclude = ['identifier']
PseudoPaymentProcessorForm.base_fields = OrderedDict([('enabled', <django.forms.fields.BooleanField object at 0x7f52fe88a7b8>), ('logo', <filer.fields.image.AdminImageFormField object at 0x7f52fe88a630>), ('bg_color', <django.forms.fields.CharField object at 0x7f52fe88a5f8>), ('fg_color', <django.forms.fields.CharField object at 0x7f52fe88a2e8>), ('name', <django.forms.fields.CharField object at 0x7f52fe901cc0>)])
PseudoPaymentProcessorForm.declared_fields = OrderedDict([('name', <django.forms.fields.CharField object at 0x7f52fe901cc0>)])
PseudoPaymentProcessorForm.media
class shoop.testing.service_forms.PaymentWithCheckoutPhaseForm(**kwargs)[source]

Bases: shoop.admin.forms._base.ShoopAdminForm

class Meta[source]

Bases: object

model

alias of PaymentWithCheckoutPhase

exclude = ['identifier']
PaymentWithCheckoutPhaseForm.base_fields = OrderedDict([('enabled', <django.forms.fields.BooleanField object at 0x7f52fe88aac8>), ('logo', <filer.fields.image.AdminImageFormField object at 0x7f52fe88ab70>), ('name', <django.forms.fields.CharField object at 0x7f52fe88a198>)])
PaymentWithCheckoutPhaseForm.declared_fields = OrderedDict([('name', <django.forms.fields.CharField object at 0x7f52fe88a198>)])
PaymentWithCheckoutPhaseForm.media
class shoop.testing.service_forms.CarrierWithCheckoutPhaseForm(**kwargs)[source]

Bases: shoop.admin.forms._base.ShoopAdminForm

class Meta[source]

Bases: object

model

alias of CarrierWithCheckoutPhase

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

shoop.testing.simple_checkout_phase module

class shoop.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 0x7f52fe8dba58>)])
declared_fields = OrderedDict([('input_field', <django.forms.fields.BooleanField object at 0x7f52fe8dba58>)])
media
class shoop.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 0x7f52ffc80cf8>)])
declared_fields = OrderedDict([('input_field', <django.forms.fields.CharField object at 0x7f52ffc80cf8>)])
media
class shoop.testing.simple_checkout_phase.TestMethodCheckoutPhase(**kwargs)[source]

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

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

template_name = 'shoop_testing/simple_checkout_phase.jinja'
data_attribute = None
storage_identifier = None
get_initial()[source]
form_valid(form)[source]
is_valid()[source]
process()[source]
class shoop.testing.simple_checkout_phase.TestPaymentCheckoutPhase(**kwargs)[source]

Bases: shoop.testing.simple_checkout_phase.TestMethodCheckoutPhase

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

identifier = 'test_payment_phase'
title = 'Test Payment Phase'
form_class

alias of TestPaymentCheckoutPhaseForm

storage_identifier = 'payment_with_checkout_phase'
data_attribute = 'payment_data'
class shoop.testing.simple_checkout_phase.TestShipmentCheckoutPhase(**kwargs)[source]

Bases: shoop.testing.simple_checkout_phase.TestMethodCheckoutPhase

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

identifier = 'test_shipment_phase'
title = 'Test Shipment Phase'
form_class

alias of TestShipmentCheckoutPhaseForm

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

Bases: shoop.front.checkout.BasicServiceCheckoutPhaseProvider

phase_class

alias of TestPaymentCheckoutPhase

service_provider_class

alias of PaymentWithCheckoutPhase

class shoop.testing.simple_checkout_phase.ShipmentPhaseProvider[source]

Bases: shoop.front.checkout.BasicServiceCheckoutPhaseProvider

phase_class

alias of TestShipmentCheckoutPhase

service_provider_class

alias of CarrierWithCheckoutPhase

shoop.testing.soup_utils module

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

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

shoop.testing.text_data module

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

shoop.testing.utils module

shoop.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

Module contents

class shoop.testing.ShoopTestingAppConfig(*args, **kwargs)[source]

Bases: shoop.apps.AppConfig

name = 'shoop.testing'
verbose_name = 'Shoop Testing & Demo Utilities'
label = 'shoop_testing'
provides = {'front_service_checkout_phase_provider': ['shoop.testing.simple_checkout_phase.PaymentPhaseProvider', 'shoop.testing.simple_checkout_phase.ShipmentPhaseProvider'], 'service_provider_admin_form': ['shoop.testing.service_forms:PseudoPaymentProcessorForm', 'shoop.testing.service_forms:PaymentWithCheckoutPhaseForm', 'shoop.testing.service_forms:CarrierWithCheckoutPhaseForm'], 'admin_module': ['shoop.testing.admin_module:TestingAdminModule']}