当前位置: 首页>>代码示例>>Python>>正文


Python factories.get_default_shop函数代码示例

本文整理汇总了Python中shuup.testing.factories.get_default_shop函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_shop函数的具体用法?Python get_default_shop怎么用?Python get_default_shop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_default_shop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_behavior_delete_save

def test_behavior_delete_save(rf, admin_user, view, model, get_object, service_provider_attr):
    """
    Only testing one initial behavior component
    """
    get_default_shop()
    with override_settings(LANGUAGES=[("en", "en")]):
        object = get_object()
        view = view.as_view()
        service_provider_attr_field = "base-%s" % service_provider_attr

        component = WeightLimitsBehaviorComponent.objects.create(min_weight=0, max_weight=1)
        object.behavior_components.add(component)
        components_before = object.behavior_components.count()
        assert components_before == 1

        data = get_default_data(object, service_provider_attr, service_provider_attr_field, delete=True)
        data["weightlimitsbehaviorcomponent-0-id"] = component.id
        data["weightlimitsbehaviorcomponent-INITIAL_FORMS"] = 1
        data["weightlimitsbehaviorcomponent-TOTAL_FORMS"] = 2

        request = apply_request_middleware(rf.post("/", data=data, user=admin_user))
        response = view(request, pk=object.pk)
        if hasattr(response, "render"):
            response.render()
        components_after = object.behavior_components.count()
        assert not components_after

        assert not WaivingCostBehaviorComponent.objects.first()
开发者ID:ahmadzai,项目名称:shuup,代码行数:28,代码来源:test_service_behavior_components.py

示例2: test_campaign_new_mode_view_formsets

def test_campaign_new_mode_view_formsets(rf, admin_user):
    view = BasketCampaignEditView
    get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    form_parts = get_form_parts(request, view, view.model())
    assert len(form_parts) == 1
    assert issubclass(form_parts[0].__class__, BasketBaseFormPart)
开发者ID:NamiStudio,项目名称:shuup,代码行数:7,代码来源:test_basket_campaign_admin.py

示例3: test_refund_without_shipment

def test_refund_without_shipment(restock):
    shop = get_default_shop()
    supplier = get_simple_supplier()
    product = create_product(
        "test-sku",
        shop=get_default_shop(),
        default_price=10,
    )
    # Start out with a supplier with quantity of 10 of a product
    supplier.adjust_stock(product.id, 10)
    check_stock_counts(supplier, product, physical=10, logical=10)

    order = create_order_with_product(product, supplier, 2, 200, shop=shop)
    order.cache_prices()
    check_stock_counts(supplier, product, physical=10, logical=8)

    # Restock value shouldn't matter if we don't have any shipments
    product_line = order.lines.first()
    order.create_refund([
        {"line": product_line, "quantity": 2, "amount": Money(400, order.currency), "restock_products": restock}])

    if restock:
        check_stock_counts(supplier, product, physical=10, logical=10)
    else:
        check_stock_counts(supplier, product, physical=10, logical=8)
    assert product_line.refunded_quantity == 2
    assert order.get_total_tax_amount() == Money(
        order.taxful_total_price_value - order.taxless_total_price_value,
        order.currency)
开发者ID:ruqaiya,项目名称:shuup,代码行数:29,代码来源:test_orders.py

示例4: test_login_inactive_user_fails

def test_login_inactive_user_fails(client, regular_user, rf):
    if "shuup.front.apps.auth" not in settings.INSTALLED_APPS:
        pytest.skip("Need shuup.front.apps.auth in INSTALLED_APPS")

    get_default_shop()
    prepare_user(regular_user)

    response = client.post(reverse("shuup:login"), data={
        "username": regular_user.username,
        "password": REGULAR_USER_PASSWORD,
    })

    request = rf.get("/")
    request.session = client.session
    assert get_user(request) == regular_user, "User is logged in"

    request = rf.get("/")
    request.session = client.session
    logout(request)

    user_contact = regular_user.contact
    assert user_contact.is_active

    user_contact.is_active = False
    user_contact.save()

    client.post(reverse("shuup:login"), data={
        "username": regular_user.username,
        "password": REGULAR_USER_PASSWORD,
    })

    request = rf.get("/")
    request.session = client.session
    assert get_user(request).is_anonymous(), "User is still anonymous"
开发者ID:suutari,项目名称:shoop,代码行数:34,代码来源:test_auth.py

示例5: test_campaign_edit_save

def test_campaign_edit_save(rf, admin_user):
    """
    To make things little bit more simple let's use only english as
    a language.
    """
    with override_settings(LANGUAGES=[("en", "en")]):
        shop = get_default_shop()
        object = BasketCampaign.objects.create(name="test campaign", active=True, shop=shop)
        object.save()
        view = BasketCampaignEditView.as_view()
        new_name = "Test Campaign"
        assert object.name != new_name
        data = {
            "base-name": new_name,
            "base-public_name__en": "Test Campaign",
            "base-shop": get_default_shop().id,
            "base-active": True,
            "base-basket_line_text": "Test campaign activated!"
        }
        methods_before = BasketCampaign.objects.count()
        # Conditions and effects is tested separately
        with override_provides("campaign_basket_condition", []):
            with override_provides("campaign_basket_discount_effect_form", []):
                with override_provides("campaign_basket_line_effect_form", []):
                    request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
                    response = view(request, pk=object.pk)
                    assert response.status_code in [200, 302]

        assert BasketCampaign.objects.count() == methods_before
        assert BasketCampaign.objects.get(pk=object.pk).name == new_name
开发者ID:NamiStudio,项目名称:shuup,代码行数:30,代码来源:test_basket_campaign_admin.py

示例6: test_campaign_end_date

def test_campaign_end_date(rf, admin_user):
    """
    To make things little bit more simple let's use only english as
    a language.
    """
    with override_settings(LANGUAGES=[("en", "en")]):
        shop = get_default_shop()
        old_name = "test_campaign"
        object = CatalogCampaign.objects.create(name=old_name, active=True, shop=shop)
        object.save()
        view = CatalogCampaignEditView.as_view()
        new_name = "Test Campaign"
        assert object.name != new_name
        data = {
            "base-name": new_name,
            "base-public_name__en": "Test Campaign",
            "base-shop": get_default_shop().id,
            "base-active": True,
            "base-basket_line_text": "Test campaign activated!",
            "base-start_datetime": datetime.datetime(year=2016, month=6, day=19),
            "base-end_datetime": datetime.datetime(year=2016, month=6, day=10)
        }
        methods_before = CatalogCampaign.objects.count()
        # Conditions, effects and effects is tested separately
        with override_provides("campaign_context_condition", []):
            with override_provides("campaign_catalog_filter", []):
                with override_provides("campaign_product_discount_effect_form", []):
                    request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
                    response = view(request, pk=object.pk)
                    assert response.status_code in [200, 302]
                    content = response.render().content.decode("utf-8")
                    assert "Campaign end date can't be before start date." in content
        assert CatalogCampaign.objects.count() == methods_before
        assert CatalogCampaign.objects.get(pk=object.pk).name == old_name
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_catalog_campaign_admin.py

示例7: test_category_links_plugin_with_customer

def test_category_links_plugin_with_customer(rf, show_all_categories):
    """
    Test plugin for categories that is visible for certain group
    """
    shop = get_default_shop()
    group = get_default_customer_group()
    customer = create_random_person()
    customer.groups.add(group)
    customer.save()

    request = rf.get("/")
    request.shop = get_default_shop()
    apply_request_middleware(request)
    request.customer = customer

    category = get_default_category()
    category.status = CategoryStatus.VISIBLE
    category.visibility = CategoryVisibility.VISIBLE_TO_GROUPS
    category.visibility_groups.add(group)
    category.shops.add(shop)
    category.save()

    vars = {"request": request}
    context = get_jinja_context(**vars)
    plugin = CategoryLinksPlugin({"categories": [category.pk], "show_all_categories": show_all_categories})
    assert category.is_visible(customer)
    assert category in plugin.get_context_data(context)["categories"]

    customer_without_groups = create_random_person()
    customer_without_groups.groups.clear()

    assert not category.is_visible(customer_without_groups)
    request.customer = customer_without_groups
    context = get_jinja_context(**vars)
    assert category not in plugin.get_context_data(context)["categories"]
开发者ID:NamiStudio,项目名称:shuup,代码行数:35,代码来源:test_plugins.py

示例8: test_register_api

def test_register_api():
    get_default_shop()
    configuration.set(None, "api_permission_FrontUserViewSet", PermissionLevel.PUBLIC_WRITE)
    client = _get_client()
    register_data = {
        "username": "goodusername",
        "password": "somepassword"
    }
    response = client.post("/api/shuup/front/user/",
                           content_type="application/json",
                           data=json.dumps(register_data))
    assert response.status_code == status.HTTP_201_CREATED
    response_json = json.loads(response.content.decode("utf-8"))
    assert "token" in response_json
    assert get_user_model().objects.count() == 1

    # Try to register with same username
    register_data = {
        "username": "goodusername",
        "password": "somepassword"
    }
    response = client.post("/api/shuup/front/user/",
                           content_type="application/json",
                           data=json.dumps(register_data))
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert "User already exists" in response.content.decode("utf-8")
开发者ID:suutari-ai,项目名称:shuup,代码行数:26,代码来源:test_front_users_api.py

示例9: test_register_bad_data

def test_register_bad_data():
    get_default_shop()
    client = _get_client()
    # no username or email
    register_data = {
        "password": "somepassword"
    }
    response = client.post("/api/shuup/front/user/",
                           content_type="application/json",
                           data=json.dumps(register_data))
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert "username and/or email is required" in response.content.decode("utf-8")

    # invalid email
    register_data = {
        "email": "invalidemail",
        "password": "somepassword"
    }
    response = client.post("/api/shuup/front/user/",
                           content_type="application/json",
                           data=json.dumps(register_data))
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert "Enter a valid email address" in response.content.decode("utf-8")

    # no password
    register_data = {
        "email": "[email protected]",
    }
    response = client.post("/api/shuup/front/user/",
                           content_type="application/json",
                           data=json.dumps(register_data))
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert "password" in json.loads(response.content.decode("utf-8"))
开发者ID:suutari-ai,项目名称:shuup,代码行数:33,代码来源:test_front_users_api.py

示例10: test_order_creator_view_for_customer

def test_order_creator_view_for_customer(rf, admin_user):
    get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    request = apply_request_middleware(rf.get("/", {"contact_id": contact.id}), user=admin_user)
    response = OrderEditView.as_view()(request)
    assert_contains(response, "customerData")  # in the config
    assert_contains(response, "isCompany")  # in the config
开发者ID:NamiStudio,项目名称:shuup,代码行数:7,代码来源:test_order_creator.py

示例11: test_custom_view_toolbar_buttons

def test_custom_view_toolbar_buttons(rf, admin_user):
    factories.get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    list_view_func = ContactGroupPriceDisplayListView.as_view()
    edit_view_func = ContactGroupPriceDisplayEditView.as_view()

    with override_provides("contact_group_price_list_toolbar_provider", [
        "shuup.testing.modules.mocker.toolbar:ContactGroupPriceDisplayButtonProvider"
    ]):
        list_response = list_view_func(request)
        list_response.render()
        list_content = list_response.content.decode("utf-8")
        assert "btn-contact-group-hello" in list_content

        edit_response = edit_view_func(request)
        edit_response.render()
        edit_response = edit_response.content.decode("utf-8")
        assert "btn-contact-group-hello" not in edit_response

    # use global provider - all views should have that button
    with override_provides("admin_toolbar_button_provider", [
        "shuup.testing.modules.mocker.toolbar:ContactGroupPriceDisplayButtonProvider"
    ]):
        list_response = list_view_func(request)
        list_response.render()
        list_content = list_response.content.decode("utf-8")
        assert "btn-contact-group-hello" in list_content

        edit_response = edit_view_func(request)
        edit_response.render()
        edit_response = edit_response.content.decode("utf-8")
        assert "btn-contact-group-hello" in edit_response
开发者ID:ruqaiya,项目名称:shuup,代码行数:32,代码来源:test_view_custom_toolbar.py

示例12: test_user_will_be_redirected_to_user_account_page_after_activation

def test_user_will_be_redirected_to_user_account_page_after_activation(client):
    """
    1. Register user
    2. Dig out the urls from the email
    3. Get the url and see where it redirects
    4. See that user's email is in content (in input)
    5. Check that the url poins to user_account-page
    """
    if "shuup.front.apps.registration" not in settings.INSTALLED_APPS:
        pytest.skip("shuup.front.apps.registration required in installed apps")
    if "shuup.front.apps.customer_information" not in settings.INSTALLED_APPS:
        pytest.skip("shuup.front.apps.customer_information required in installed apps")

    get_default_shop()
    response = client.post(reverse("shuup:registration_register"), data={
        "username": username,
        "email": email,
        "password1": "password",
        "password2": "password",
    }, follow=True)
    body = mail.outbox[-1].body
    urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[[email protected]&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', body)
    response = client.get(urls[0], follow=True)
    assert email.encode('utf-8') in response.content, 'email should be found from the page.'
    assert reverse('shuup:customer_edit') == response.request['PATH_INFO'], 'user should be on the account-page.'
开发者ID:hrayr-artunyan,项目名称:shuup,代码行数:25,代码来源:test_registration.py

示例13: test_sorts_and_filter_in_category_edit

def test_sorts_and_filter_in_category_edit(rf, admin_user):
    get_default_shop()
    cache.clear()
    activate("en")
    with override_provides("front_extend_product_list_form", DEFAULT_FORM_MODIFIERS):
        category = get_default_category()
        view = CategoryEditView.as_view()
        assert get_configuration(category=category) == settings.SHUUP_FRONT_DEFAULT_SORT_CONFIGURATION
        data = {
            "base-name__en": category.name,
            "base-status": category.status.value,
            "base-visibility": category.visibility.value,
            "base-ordering": category.ordering,
            "product_list_facets-sort_products_by_name": True,
            "product_list_facets-sort_products_by_name_ordering": 6,
            "product_list_facets-sort_products_by_price": False,
            "product_list_facets-sort_products_by_price_ordering": 32,
            "product_list_facets-filter_products_by_manufacturer": True,
            "product_list_facets-filter_products_by_manufacturer_ordering": 1
        }
        request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
        response = view(request, pk=category.pk)
        if hasattr(response, "render"):
            response.render()
        assert response.status_code in [200, 302]
        expected_configurations = {
            "sort_products_by_name": True,
            "sort_products_by_name_ordering": 6,
            "sort_products_by_price": False,
            "sort_products_by_price_ordering": 32,
            "filter_products_by_manufacturer": True,
            "filter_products_by_manufacturer_ordering": 1
        }
        assert get_configuration(category=category) == expected_configurations
开发者ID:suutari,项目名称:shoop,代码行数:34,代码来源:test_sorts_and_filters_admin.py

示例14: test_new_service_providers_type_select

def test_new_service_providers_type_select(rf, admin_user, sp_model, type_param):
    """
    Test `ServiceProvideEditView`` with different types of
    ``ServiceProvider`` subclasses. Make sure that view is rendered
    and creating new object works.

    To make things little bit more simple let's use only english as
    an language.
    """
    with override_settings(LANGUAGES=[("en", "en")]):
        get_default_shop()
        view = ServiceProviderEditView.as_view()
        url = "/"
        if type_param:
            url += "?type=%s" % type_param
        soup = get_bs_object_for_view(rf.get(url), view, admin_user)
        selected_type = soup.find("select", attrs={"id": "id_type"}).find("option", selected=True)["value"]
        if type_param:
            assert type_param == selected_type
        else:
            assert selected_type in [
                "shuup.customcarrier", "shuup.custompaymentprocessor",
                "shuup_testing.pseudopaymentprocessor"
            ]

        if sp_model:
            name = "Some provider"
            data = {
                "type": type_param,
                "name__en": name,
                "enabled": True
            }
            provider_count = sp_model.objects.count()
            get_bs_object_for_view(rf.post(url, data=data), view, admin_user)
            assert sp_model.objects.count() == provider_count + 1
开发者ID:ahmadzai,项目名称:shuup,代码行数:35,代码来源:test_service_providers.py

示例15: test_theme_with_default_template_dir

def test_theme_with_default_template_dir():
    get_default_shop()
    with override_current_theme_class(ShuupTestingThemeWithCustomBase):
        c = SmartClient()
        soup = c.soup(reverse("shuup:index"))
        assert "Simple base for themes to use" in soup.find("h1").text
        assert "Welcome to test Shuup!" in soup.find("h1").text
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_default_template_dir.py


注:本文中的shuup.testing.factories.get_default_shop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。