Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add test
fowczarekc5226aff6486
diff --git a/tests/conftest.py b/tests/conftest.pyindex e8a706a104..dea3ca2e3d 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -255,11 +255,22 @@ def category_with_image(db, image): # pylint: disable=W0613@pytest.fixture-def categories_tree(db):+def categories_tree(db, product_type): # pylint: disable=W0613parent = Category.objects.create(name='Parent', slug='parent')parent.children.create(name='Child', slug='child')+ child = parent.children.first()++ product_attr = product_type.product_attributes.first()+ attr_value = product_attr.values.first()+ attributes = {smart_text(product_attr.pk): smart_text(attr_value.pk)}++ Product.objects.create(+ name='Test product', price=Money('10.00', 'USD'),+ product_type=product_type, attributes=attributes, category=child)+return parent+@pytest.fixturedef non_default_category(db): # pylint: disable=W0613return Category.objects.create(name='Not default', slug='not-default')diff --git a/tests/test_category.py b/tests/test_category.pynew file mode 100644index 0000000000..999e42316b--- /dev/null+++ b/tests/test_category.py@@ -0,0 +1,12 @@+from saleor.product.filters import ProductCategoryFilter+++def test(product_type, categories_tree):+ product_filter = ProductCategoryFilter(data={}, category=categories_tree)+ (product_attributes, variant_attributes) = product_filter._get_attributes()++ attribut = product_type.product_attributes.get()+ variant = product_type.variant_attributes.get()++ assert attribut in product_attributes+ assert variant in variant_attributes