Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add tests for dashboard product search
Jakub Draganekb3f61812af98
diff --git a/tests/test_postgresql_search.py b/tests/test_postgresql_search.pyindex f58e8539f5..740b9891cf 100644--- a/tests/test_postgresql_search.py+++ b/tests/test_postgresql_search.py@@ -1,6 +1,9 @@from __future__ import unicode_literals+from saleor.product.models import Product+from django.core.urlresolvers import reverse+from decimal import Decimalimport pytest@@ -17,7 +20,47 @@ def test_dummy_integration(client):client.get(reverse('search:search'), {'q': phrase})+PRODUCTS = [('Arabica Coffee', 'The best grains in galactic'),+ ('Cool T-Shirt', 'Blue and big.'),+ ('Roasted chicken', 'Fabulous vertebrate')]+++def named_products(default_category, product_class):+ products = []+ for name, description in PRODUCTS:+ product = Product.objects.create(+ name=name,+ description=description,+ price=Decimal(6.6),+ product_class=product_class)+ product.categories.add(default_category)+ products.append(product)+ return products++@pytest.mark.integration-def test_dummy_dashboard_integration(client):[email protected]_db(transaction=True)+def test_search_empty_results(admin_client, named_products):phrase = 'foo'- client.get(reverse('dashboard:search'), {'q': phrase})+ resp = admin_client.get(reverse('dashboard:search'), {'q': phrase})+ assert 0 == len(resp.context['products'])+ assert phrase == resp.context['query']++[email protected]_db(transaction=True)+def test_find_product_by_name(admin_client, named_products):+ phrase = 'Coffee'+ resp = admin_client.get(reverse('dashboard:search'), {'q': phrase})+ assert 1 == len(resp.context['products'])+ assert named_products[0] in resp.context['products']++[email protected]_db(transaction=True)+def test_find_product_by_description(admin_client, named_products):+ phrase = 'big'+ resp = admin_client.get(reverse('dashboard:search'), {'q': phrase})+ assert 1 == len(resp.context['products'])+ assert named_products[1] in resp.context['products']