<commit_before># -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2018, Shuup Inc. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
import os

import pytest

from django.core.urlresolvers import reverse
from django.utils.translation import activate

from shuup.core import cache
from shuup.core.models import (
    Category, CategoryStatus, Manufacturer, Product, ProductMode,
    ProductVariationVariable, ProductVariationVariableValue, ShopProduct,
    ShopProductVisibility
)
from shuup.front.utils.sorts_and_filters import (
    set_configuration
)
from shuup.testing.browser_utils import click_element, wait_until_condition
from shuup.testing.factories import (
    create_product, get_default_shop, get_default_supplier
)
from shuup.testing.utils import initialize_front_browser_test

pytestmark = pytest.mark.skipif(os.environ.get("SHUUP_BROWSER_TESTS", "0") != "1", reason="No browser tests run.")


CATEGORY_DATA = [
    ("First Category", "cat-1"),
    ("Second Category", "cat-2"),
    ("Third Category", "cat-3"),
]


MANUFACTURER_DATA = [
    ("First Manufacturer", "man-1"),
    ("Second Manufacturer", "man-2"),
]

FIRST_CATEGORY_PRODUCT_DATA = [
    ("Test Product", "test-sku-1", 123),
    ("A Test Product", "test-sku-2", 720),
    ("XTest Product", "test-sku-3", 1),
]


@pytest.mark.browser
@pytest.mark.djangodb
def test_category_product_filters_1(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # 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)
    second_category_page_change(browser, live_server, shop, second_cat)


@pytest.mark.browser
@pytest.mark.djangodb
def test_category_product_filters_2(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # Activate limit page size changer for the shop
    set_configuration(
        shop=shop,
        data={
            "sort_products_by_name": True,
            "sort_products_by_name_ordering": 1,
            "sort_products_by_price": True,
            "sort_products_by_price_ordering": 2,
            "limit_product_list_page_size": True
        }
    )

    # 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
    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)


@pytest.mark.browser
@pytest.mark.djangodb
def test_category_product_filters_3(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # 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)
<commit_msg>Browser tests: Disable `test_category_product_filters_3`<commit_after># -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2018, Shuup Inc. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
import os

import pytest

from django.core.urlresolvers import reverse
from django.utils.translation import activate

from shuup.core import cache
from shuup.core.models import (
    Category, CategoryStatus, Manufacturer, Product, ProductMode,
    ProductVariationVariable, ProductVariationVariableValue, ShopProduct,
    ShopProductVisibility
)
from shuup.front.utils.sorts_and_filters import (
    set_configuration
)
from shuup.testing.browser_utils import click_element, wait_until_condition
from shuup.testing.factories import (
    create_product, get_default_shop, get_default_supplier
)
from shuup.testing.utils import initialize_front_browser_test

pytestmark = pytest.mark.skipif(os.environ.get("SHUUP_BROWSER_TESTS", "0") != "1", reason="No browser tests run.")


CATEGORY_DATA = [
    ("First Category", "cat-1"),
    ("Second Category", "cat-2"),
    ("Third Category", "cat-3"),
]


MANUFACTURER_DATA = [
    ("First Manufacturer", "man-1"),
    ("Second Manufacturer", "man-2"),
]

FIRST_CATEGORY_PRODUCT_DATA = [
    ("Test Product", "test-sku-1", 123),
    ("A Test Product", "test-sku-2", 720),
    ("XTest Product", "test-sku-3", 1),
]


@pytest.mark.browser
@pytest.mark.djangodb
def test_category_product_filters_1(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # 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)
    second_category_page_change(browser, live_server, shop, second_cat)


@pytest.mark.browser
@pytest.mark.djangodb
def test_category_product_filters_2(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # Activate limit page size changer for the shop
    set_configuration(
        shop=shop,
        data={
            "sort_products_by_name": True,
            "sort_products_by_name_ordering": 1,
            "sort_products_by_price": True,
            "sort_products_by_price_ordering": 2,
            "limit_product_list_page_size": True
        }
    )

    # 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
    second_category_sort_test(browser, live_server, shop, second_cat)
    second_category_sort_with_price_filter(browser, second_cat)


@pytest.mark.browser
@pytest.mark.djangodb
@pytest.mark.skipif(os.environ.get("SHUUP_TESTS_TRAVIS", "0") == "1", reason="Disable when run through tox.")
def test_category_product_filters_3(browser, live_server, settings):
    cache.clear()  # Avoid cache from past tests
    shop, first_cat, second_cat, third_cat, first_manufacturer = initialize_db()

    # 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)

{'fraction_non_alphanumeric': 0.10518746789933231, 'fraction_numerical': 0.007087827426810477, 'mean_word_length': 4.781472684085511, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2228113', 'n_tokens_mistral': 3121, 'n_tokens_neox': 3063, 'n_words': 735}