Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add test for dashboard user search with email
Jakub Draganek4af66c4700a7
diff --git a/tests/test_postgresql_search.py b/tests/test_postgresql_search.pyindex 78a901a03f..c059c47284 100644--- a/tests/test_postgresql_search.py+++ b/tests/test_postgresql_search.py@@ -1,3 +1,4 @@+# -*- coding: utf-8 -*-from __future__ import unicode_literalsfrom saleor.product.models import Product@@ -92,23 +93,29 @@ def test_find_product_by_description(admin_client, named_products):assert named_products[1] in products-ORDERS = [(10, 'Andreas', 'Knop', '[email protected]'),- (45, 'Euzebiusz', 'Ziemniak', '[email protected]'),- (13, 'John', 'Doe', '[email protected]')]+USERS = [('Andreas', 'Knop', '[email protected]'),+ ('Euzebiusz', 'Ziemniak', '[email protected]'),+ ('John', 'Doe', '[email protected]')]+ORDER_IDS = [10, 45, 13]+ORDERS = [(pk, *user) for pk, user in zip(ORDER_IDS, USERS)]-def orders_with_addresses():- orders = []- for pk, name, lastname, email in ORDERS:- addr = Address.objects.create(- first_name=name,- last_name=lastname,+def gen_address_for_user(first_name, last_name):+ return Address.objects.create(+ first_name=first_name,+ last_name=last_name,company_name='Mirumee Software',street_address_1='Tęczowa 7',city='Wrocław',postal_code='53-601',country='PL')+++def orders_with_addresses():+ orders = []+ for pk, name, lastname, email in ORDERS:+ addr = gen_address_for_user(name, lastname)user = User.objects.create(default_shipping_address=addr, email=email)order = Order.objects.create(user=user, billing_address=addr, pk=pk)orders.append(order)@@ -146,9 +153,30 @@ def test_find_order_with_email(admin_client, orders_with_addresses, phrase,@pytest.mark.integration@pytest.mark.django_db(transaction=True)@pytest.mark.parametrize('phrase,order_num', [('knop', 0), ('ZIEMniak', 1),- ('john', 2), ('ANDREAS', 0)])+ (' john ', 2), ('ANDREAS', 0)])def test_find_order_with_user(admin_client, orders_with_addresses, phrase,order_num):_, orders, _ = search_dashboard(admin_client, phrase)assert 1 == len(orders)assert orders_with_addresses[order_num] in orders+++def users_with_addresses():+ users = []+ for firstname, lastname, email in USERS:+ addr = gen_address_for_user(firstname, lastname)+ user = User.objects.create(default_billing_address=addr, email=email)+ users.append(user)+ return users++[email protected]_db(transaction=True)[email protected]('phrase,user_num', [('[email protected]', 0),+ (' [email protected] ', 1)])+def test_find_user_with_email(admin_client, users_with_addresses, phrase,+ user_num):+ _, _, users = search_dashboard(admin_client, phrase)+ assert 1 == len(users)+ assert users_with_addresses[user_num] in users