Esempio n. 1
0
def test_orders_list_view(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    for i in range(0, 10):
        order = create_empty_order(shop=shop)
        order.save()

    # Set last one canceled
    Order.objects.last().set_canceled()

    initialize_admin_browser_test(browser, live_server, settings)
    _visit_orders_list_view(browser, live_server)
    _test_status_filter(browser)  # Will set three orders from end canceled
Esempio n. 2
0
def test_list_views(browser, admin_user, live_server, settings, visit_type):
    shop = get_default_shop()
    creator = list_view_settings[visit_type].get("creator", None)

    if creator and callable(creator):
        creator(shop)

    initialize_admin_browser_test(browser, live_server, settings)
    _visit_list_view(browser, live_server, visit_type)
    if list_view_settings[visit_type].get("test_pagination", False):
        _test_pagination(browser)
    _set_settings(browser, visit_type)
Esempio n. 3
0
def test_product_detail(browser, admin_user, live_server, settings):
    activate(settings.PARLER_DEFAULT_LANGUAGE_CODE)
    shop = get_default_shop()
    order = create_empty_order(shop=shop)
    order.save()
    initialize_admin_browser_test(browser, live_server, settings)
    url = reverse("wshop_admin:order.detail", kwargs={"pk": order.pk})
    browser.visit("%s%s" % (live_server, url))
    wait_until_condition(
        browser, condition=lambda x: x.is_text_present("Order %s" % order.pk))

    change_addresses(live_server, browser, order)

    set_status(browser, order, OrderStatus.objects.get_default_processing())
    assert order.can_set_complete()
    set_status(browser, order, OrderStatus.objects.get_default_complete())
Esempio n. 4
0
def test_refunds(browser, admin_user, live_server, settings):
    order = create_order_with_product(get_default_product(),
                                      get_default_supplier(),
                                      10,
                                      decimal.Decimal("10"),
                                      n_lines=10,
                                      shop=get_default_shop())
    order2 = create_order_with_product(get_default_product(),
                                       get_default_supplier(),
                                       10,
                                       decimal.Decimal("10"),
                                       n_lines=10,
                                       shop=get_default_shop())
    order2.create_payment(order2.taxful_total_price)
    initialize_admin_browser_test(browser, live_server, settings)
    _test_toolbar_visibility(browser, live_server, order)
    _test_create_full_refund(browser, live_server, order)
    _test_refund_view(browser, live_server, order2)
Esempio n. 5
0
def test_order_creator_view_1(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    get_default_payment_method()
    get_default_shipping_method()
    get_initial_order_status()
    supplier = get_default_supplier()
    person = create_random_person()
    create_product("test-sku0", shop=shop, default_price=10, supplier=supplier)
    create_product("test-sku1", shop=shop, default_price=10, supplier=supplier)
    object_created.connect(_add_custom_order_created_message,
                           sender=Order,
                           dispatch_uid="object_created_signal_test")

    initialize_admin_browser_test(browser, live_server, settings)
    _visit_order_creator_view(browser, live_server)
    _test_language_change(browser)
    _test_customer_data(browser, person)
    _test_regions(browser, person)
    _test_quick_add_lines(browser)
Esempio n. 6
0
def test_product_create(browser, admin_user, live_server, settings):
    activate("en")
    shop = get_default_shop()
    get_default_product_type()
    get_default_sales_unit()
    get_default_tax_class()
    configuration.set(None, "wshop_product_tour_complete", True)
    object_created.connect(_add_custom_product_created_message,
                           sender=Product,
                           dispatch_uid="object_created_signal_test")
    initialize_admin_browser_test(browser, live_server, settings)
    browser.driver.set_window_size(1920, 1080)

    url = reverse("wshop_admin:shop_product.new")
    browser.visit("%s%s" % (live_server, url))
    sku = "testsku"
    name = "Some product name"
    price_value = 10
    short_description = "short but gold"

    browser.fill("base-sku", sku)
    browser.fill("base-name__en", name)
    browser.fill("base-short_description__en", short_description)
    browser.fill("shop%s-default_price_value" % shop.pk, price_value)

    configuration.set(None, "wshop_category_tour_complete", True)
    _add_primary_category(browser, shop)
    _add_additional_category(browser, shop)

    click_element(browser, "button[form='product_form']")
    wait_until_appeared(browser, "div[class='message success']")
    product = Product.objects.filter(sku=sku).first()
    assert product.log_entries.filter(
        identifier=OBJECT_CREATED_LOG_IDENTIFIER).count() == 1
    object_created.disconnect(sender=Product,
                              dispatch_uid="object_created_signal_test")
    shop_product = product.get_shop_instance(shop)
    assert shop_product.categories.count() == 2
Esempio n. 7
0
def test_product_detail(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    product = create_product("test_sku", shop, default_price=10)
    configuration.set(None, "wshop_product_tour_complete", True)
    initialize_admin_browser_test(browser, live_server, settings)

    url = reverse("wshop_admin:shop_product.edit",
                  kwargs={"pk": product.get_shop_instance(shop).pk})
    browser.visit("%s%s" % (live_server, url))
    assert browser.find_by_id("id_base-sku").value == product.sku

    # Test product save
    new_sku = "some-new-sku"
    browser.find_by_id("id_base-sku").fill(new_sku)
    browser.execute_script("window.scrollTo(0,0)")
    click_element(browser, "button[form='product_form']")

    wait_until_condition(
        browser, condition=lambda x: x.is_text_present("Product edited"))

    product.refresh_from_db()
    check_product_name(browser, product, new_sku)

    # Test that toolbar action item is there
    dropdowns = browser.find_by_css(".btn.dropdown-toggle")
    for dropdown in dropdowns:
        if "Actions" in dropdown.text:
            dropdown.click()

    wait_until_appeared(browser, "a[href='#%s']" % product.sku)
    click_element(browser, "a[href='#%s']" % product.sku)

    # Make sure that the tabs is clickable in small devices
    browser.driver.set_window_size(480, 960)

    click_element(browser, "#product-images-section", header_height=320)
    click_element(browser, "#additional-details-section", header_height=320)
Esempio n. 8
0
def test_order_creator_view_2(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    get_initial_order_status()
    supplier = get_default_supplier()
    person = create_random_person()
    create_product("test-sku0", shop=shop, default_price=10, supplier=supplier)
    create_product("test-sku1", shop=shop, default_price=10, supplier=supplier)
    object_created.connect(_add_custom_order_created_message,
                           sender=Order,
                           dispatch_uid="object_created_signal_test")

    initialize_admin_browser_test(browser, live_server, settings)
    browser.driver.set_window_size(1920, 1080)
    _visit_order_creator_view(browser, live_server)
    _test_customer_using_search(browser, person)
    _test_add_lines(browser)
    _test_methods(browser, sm, pm)
    _test_confirm(browser)
    assert Order.objects.first().log_entries.filter(
        identifier=OBJECT_CREATED_LOG_IDENTIFIER).count() == 1
    object_created.disconnect(sender=Order,
                              dispatch_uid="object_created_signal_test")
Esempio n. 9
0
def initialize(browser, live_server, settings):
    initialize_admin_browser_test(browser, live_server, settings)