Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Remove duplicated fixtures

Jakub Draganekb21d85281af3
diff --git a/tests/test_search.py b/tests/test_search.py
index 71c66ae93c..6470b380fd 100644
--- a/tests/test_search.py
+++ b/tests/test_search.py
@@ -8,7 +8,7 @@ from decimal import Decimal
import pytest
MATCH_SEARCH_REQUEST = ['method', 'host', 'port', 'path', 'body']
-PRODUCTS_FOUND = [41, 59] # same as in recorded data!
+PRODUCTS_FOUND = [15, 34, 41, 58, 59] # same as in recorded data!
DATE_OF_RECORDING = '2017-10-18'
@@ -77,7 +77,7 @@ def test_search_with_result(db, indexed_products, client):
EXISTING_PHRASE = 'Group'
response = client.get(reverse('search:search'), {'q': EXISTING_PHRASE})
found_products = _extract_pks(response.context['results'].object_list)
- assert PRODUCTS_FOUND == sorted(found_products)
+ assert [41, 59] == sorted(found_products)
assert EXISTING_PHRASE == response.context['query']
@@ -99,38 +99,25 @@ def test_new_search_with_empty_results(db, client, new_search_backend):
assert WORD == response.context['query']
-def other_indexed_products(product_class, default_category):
- def gen_product_with_id(object_id):
- product = Product.objects.create(
- pk=object_id,
- name='Test product ' + str(object_id),
- price=Decimal(10.0),
- product_class=product_class)
- product.categories.add(default_category)
- return product
- return [gen_product_with_id(prod) for prod in [15, 58]]
-
-
@pytest.mark.integration
@pytest.mark.vcr(record_mode='once', match_on=MATCH_SEARCH_REQUEST)
-def test_new_search_with_result(db, other_indexed_products, client,
+def test_new_search_with_result(db, indexed_products, client,
new_search_backend):
EXISTING_PHRASE = 'Group'
response = client.get(reverse('search:search'), {'q': EXISTING_PHRASE})
found_products = _extract_pks(response.context['results'].object_list)
- assert [15, 58] == sorted(found_products)
+ assert [15, 34, 58] == sorted(found_products)
assert EXISTING_PHRASE == response.context['query']
@pytest.fixture
-def products_with_mixed_publishing(other_indexed_products):
+def products_with_mixed_publishing(indexed_products):
UNPUBLISH_PK = [15]
products_to_unpublish = Product.objects.filter(pk__in=UNPUBLISH_PK)
for prod in products_to_unpublish:
prod.is_published = False
prod.save()
- return other_indexed_products
+ return indexed_products
@pytest.mark.integration
@@ -140,5 +127,5 @@ def test_new_search_doesnt_show_unpublished(db, products_with_mixed_publishing,
EXISTING_PHRASE = 'Group'
response = client.get(reverse('search:search'), {'q': EXISTING_PHRASE})
found_products = _extract_pks(response.context['results'].object_list)
- assert [58] == found_products
+ assert [34, 58] == sorted(found_products)
assert EXISTING_PHRASE == response.context['query']