Ejemplo n.º 1
0
def initialize_db():
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(
        shop, Product.objects.filter(sku="test-sku-1").first(),
        ["Black", "Yellow"], ["Big", "Small"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-2").first(),
        ["Brown", "Pink"], ["S", "L", "XL"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-3").first(),
        ["Brown", "Black"], ["S", "L", "XL", "Big"]
    )

    for i in range(1, 14):
        product = create_orderable_product("Test product", "sku-%s" % i, price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)


    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(manufacturer_id=first_manufacturer.id)

    return shop, first_cat, second_cat, third_cat, first_manufacturer
Ejemplo n.º 2
0
def initialize_db():
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(
        shop, Product.objects.filter(sku="test-sku-1").first(),
        ["Black", "Yellow"], ["Big", "Small"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-2").first(),
        ["Brown", "Pink"], ["S", "L", "XL"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-3").first(),
        ["Brown", "Black"], ["S", "L", "XL", "Big"]
    )

    for i in range(1, 14):
        product = create_orderable_product("Test product", "sku-%s" % i, price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)


    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(manufacturer_id=first_manufacturer.id)

    return shop, first_cat, second_cat, third_cat, first_manufacturer
Ejemplo n.º 3
0
def test_category_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(shop,
                   Product.objects.filter(sku="test-sku-1").first(),
                   ["Black", "Yellow"], ["Big", "Small"])

    add_variations(shop,
                   Product.objects.filter(sku="test-sku-2").first(),
                   ["Brown", "Pink"], ["S", "L", "XL"])

    add_variations(shop,
                   Product.objects.filter(sku="test-sku-3").first(),
                   ["Brown", "Black"], ["S", "L", "XL", "Big"])

    for i in range(1, 14):
        product = create_orderable_product("Test product",
                                           "sku-%s" % i,
                                           price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)

    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(
        manufacturer_id=first_manufacturer.id)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    assert browser.is_text_present("Welcome to Default!")

    url = reverse("shuup:category",
                  kwargs={
                      "pk": first_cat.pk,
                      "slug": first_cat.slug
                  })
    browser.visit("%s%s" % (live_server, url))
    assert browser.is_text_present("First Category")
    assert browser.is_text_present("Sort")
    assert not browser.is_text_present(
        "Manufacturers")  # Since not in default configuration
    hide_sorts_for_shop(browser, shop)
    show_sorts_for_the_category_only(browser, first_cat)

    # All sorts for first_cat is available test sorting
    sort_category_products_test(browser, first_cat)

    manufacturer_filter_test(browser, first_cat, first_manufacturer)
    variations_filter_test(browser, first_cat)
    categories_filter_test(browser, first_cat, second_cat, third_cat)

    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)
Ejemplo n.º 4
0
def test_category_product_list(browser, live_server, settings):
    activate("en")
    # initialize
    cache.clear()
    shop = get_default_shop()

    for name, identifier in CATEGORY_DATA:
        category = Category()
        category.name = name
        category.identifier = identifier
        category.status = CategoryStatus.VISIBLE
        category.save()
        category.shops.add(shop)

    for name, identifier in MANUFACTURER_DATA:
        Manufacturer.objects.create(name=name, identifier=identifier)

    first_cat = Category.objects.filter(identifier="cat-1").first()
    second_cat = Category.objects.filter(identifier="cat-2").first()
    third_cat = Category.objects.filter(identifier="cat-3").first()
    assert first_cat.pk != second_cat.pk
    for name, sku, price in FIRST_CATEGORY_PRODUCT_DATA:
        product = create_orderable_product(name, sku, price=price)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = first_cat
        shop_product.save()
        shop_product.categories.add(first_cat)

    # Add some variation products
    add_variations(
        shop, Product.objects.filter(sku="test-sku-1").first(),
        ["Black", "Yellow"], ["Big", "Small"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-2").first(),
        ["Brown", "Pink"], ["S", "L", "XL"]
    )

    add_variations(
        shop, Product.objects.filter(sku="test-sku-3").first(),
        ["Brown", "Black"], ["S", "L", "XL", "Big"]
    )

    for i in range(1, 14):
        product = create_orderable_product("Test product", "sku-%s" % i, price=i)
        shop_product = product.get_shop_instance(shop)
        cat = Category.objects.first()
        shop_product.primary_category = second_cat
        shop_product.save()
        shop_product.categories.add(second_cat)


    # Set manufacturer for first product only
    first_manufacturer = Manufacturer.objects.first()
    Product.objects.filter(sku="test-sku-1").update(manufacturer_id=first_manufacturer.id)

    # initialize test and go to front page
    browser = initialize_front_browser_test(browser, live_server)

    # check that front page actually loaded
    wait_until_condition(browser, lambda x: x.is_text_present("Welcome to Default!"))

    url = reverse("shuup:category", kwargs={"pk": first_cat.pk, "slug": first_cat.slug})
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(browser, lambda x: x.is_text_present("First Category"))
    wait_until_condition(browser, lambda x: x.is_text_present("Sort"))
    assert not browser.is_text_present("Manufacturers")  # Since not in default configuration
    hide_sorts_for_shop(browser, shop)
    show_sorts_for_the_category_only(browser, first_cat)

    # All sorts for first_cat is available test sorting
    sort_category_products_test(browser, first_cat)

    manufacturer_filter_test(browser, first_cat, first_manufacturer)
    variations_filter_test(browser, first_cat)
    categories_filter_test(browser, first_cat, second_cat, third_cat)

    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)