shuup.testing.modules.mocker package

Submodules

shuup.testing.modules.mocker.mass_actions module

class shuup.testing.modules.mocker.mass_actions.DummyPicotableMassAction1[source]

Bases: PicotableMassAction

label = 'Dummy Mass Action #1'
identifier = 'dummy_mass_action_1'
class shuup.testing.modules.mocker.mass_actions.DummyPicotableMassAction2[source]

Bases: PicotableMassAction

label = 'Dummy Mass Action #2'
identifier = 'dummy_mass_action_2'
class shuup.testing.modules.mocker.mass_actions.DummyMassActionProvider[source]

Bases: PicotableMassActionProvider

classmethod get_mass_actions_for_view(view)[source]

Returns a list of mass actions for a given view.

Parameters:

viewdjango.views.View

Return list[PicotableMassAction]:

list of picotable mass actions definition (strings).

shuup.testing.modules.mocker.mocker_view module

class shuup.testing.modules.mocker.mocker_view.Mockers[source]

Bases: object

Namespace object for mocker methods.

The docstrings for the callables are user-visible.

mock_order(**kwargs)[source]

Create a random order (randomly completed).

mock_order_6h(**kwargs)[source]

Create a random order for past 6h (20% chance for completion).

mock_fully_paid_order(**kwargs)[source]

Create a random order (complete and fully paid).

mock_fully_paid_order_6h(**kwargs)[source]

Create a random order for past 6h (complete and fully paid).

mock_fully_paid_order_30d(**kwargs)[source]

Create a random order for past 30 days (complete and fully paid).

mock_person(**kwargs)[source]

Create a random person.

mock_company(**kwargs)[source]

Create a random company.

mock_customer_group(**kwargs)[source]

Create a random contact group.

mock_product_attribute(**kwargs)[source]

Create a random product attribute.

class shuup.testing.modules.mocker.mocker_view.MockerForm(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, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: Form

base_fields = {'count': <django.forms.fields.IntegerField object>, 'type': <django.forms.fields.ChoiceField object>}
declared_fields = {'count': <django.forms.fields.IntegerField object>, 'type': <django.forms.fields.ChoiceField object>}
property media

Return all media required to render the widgets on this form.

class shuup.testing.modules.mocker.mocker_view.MockerView(**kwargs)[source]

Bases: FormView

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

form_class

alias of MockerForm

template_name = 'shuup_testing/mocker.jinja'
mockers = <shuup.testing.modules.mocker.mocker_view.Mockers object>
get_mockers()[source]
get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

shuup.testing.modules.mocker.sections module

class shuup.testing.modules.mocker.sections.MockContactSection[source]

Bases: Section

identifier: str = 'contact_mock_section'
name: str | Any = 'mock section title'
icon: str = 'fa-globe'
template: str = 'shuup_testing/_contact_mock_section.jinja'
order: int = 9
classmethod visible_for_object(contact, request=None)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(contact, request=None)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

shuup.testing.modules.mocker.toolbar module

class shuup.testing.modules.mocker.toolbar.MockContactToolbarButton(contact, **kwargs)[source]

Bases: URLActionButton

Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

__init__(contact, **kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

class shuup.testing.modules.mocker.toolbar.MockShopToolbarButton(shop, **kwargs)[source]

Bases: URLActionButton

Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

__init__(shop, **kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

static visible_for_object(shop)[source]
class shuup.testing.modules.mocker.toolbar.MockContactToolbarActionItem(object, **kwargs)[source]

Bases: DropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.testing.modules.mocker.toolbar.MockProductToolbarActionItem(object, **kwargs)[source]

Bases: DropdownItem

Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(object, **kwargs)[source]
Parameters:
  • text – The actual text for the button.

  • icon – Icon CSS class string

  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.

  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.

  • extra_css_class (str) – Extra CSS class(es)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

class shuup.testing.modules.mocker.toolbar.MockContactGroupToolbarButton(**kwargs)[source]

Bases: URLActionButton

Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

__init__(**kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

class shuup.testing.modules.mocker.toolbar.ContactGroupPriceDisplayButtonProvider[source]

Bases: BaseToolbarButtonProvider

classmethod get_buttons_for_view(view)[source]

Implement this method to add custom buttons to a view’s toolbar

You can check the view attributes before returning buttons. In case you need to access the request, get it from the view: view.request. You can also access the view object when that is available:

``` if getattr(view, “object”, None):

yield JavaScriptActionButton(onclick=”window.doSomething()”, text=”Do Something”)

```

Parameters:

django.views.View (view) – the view object to add the toolbar.

:rtype iterator|list

Module contents

class shuup.testing.modules.mocker.TestingAdminModule[source]

Bases: AdminModule

get_urls()[source]
Return type:

list[django.urls.RegexURLPattern]

get_menu_entries(request)[source]
Return type:

list[shuup.admin.base.MenuEntry]