Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Test searching for user by email in dashboard
Jakub Draganek866e985521a3
diff --git a/tests/cassettes/test_dashboard_search_user_by_email.yaml b/tests/cassettes/test_dashboard_search_user_by_email.yamlnew file mode 100644index 0000000000..b1dca3d7d4--- /dev/null+++ b/tests/cassettes/test_dashboard_search_user_by_email.yaml@@ -0,0 +1,49 @@+interactions:+- request:+ body: '{"_source": {"exclude": ["*"]}, "query": {"multi_match": {"fields": ["user",+ "status", "discount_name"], "query": "[email protected]"}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: GET+ uri: http://search:9200/orders/order_document/_search+ response:+ body: {string: '{"took":2,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "Deprecated field [exclude] used,+ expected [excludes] instead" "Wed, 15 Nov 2017 13:19:49 GMT"']+ content-length: ['122']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"_source": {"exclude": ["*"]}, "query": {"match": {"user": "[email protected]"}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: GET+ uri: http://search:9200/users/user_document/_search+ response:+ body: {string: '{"took":2,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":2.6855774,"hits":[{"_index":"users","_type":"user_document","_id":"9","_score":2.6855774,"_source":{}}]}}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "Deprecated field [exclude] used,+ expected [excludes] instead" "Wed, 15 Nov 2017 13:19:49 GMT"']+ content-length: ['211']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"_source": {"exclude": ["*"]}, "query": {"multi_match": {"fields": ["name",+ "description"], "query": "[email protected]"}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: GET+ uri: http://search:9200/storefront/product_document/_search+ response:+ body: {string: '{"took":0,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "Deprecated field [exclude] used,+ expected [excludes] instead" "Wed, 15 Nov 2017 13:19:49 GMT"']+ content-length: ['122']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+version: 1diff --git a/tests/test_search.py b/tests/test_search.pyindex df366628cd..b33cde75a9 100644--- a/tests/test_search.py+++ b/tests/test_search.py@@ -1,11 +1,12 @@from saleor.product.models import Product+from saleor.userprofile.models import Userfrom django.core.urlresolvers import reversefrom elasticsearch_dsl.connections import connectionsfrom decimal import Decimalimport pytestMATCH_SEARCH_REQUEST = ['method', 'host', 'port', 'path', 'body']-STOREFRONT_PRODUCTS = {15,56} # same as in recorded data!+STOREFRONT_PRODUCTS = {15, 56} # same as in recorded data!DASHBOARD_PRODUCTS = {6, 29}PRODUCTS_INDEXED = STOREFRONT_PRODUCTS | DASHBOARD_PRODUCTSPRODUCTS_TO_UNPUBLISH = {56} # choose from PRODUCTS_INDEXED@@ -115,3 +116,22 @@ def test_dashboard_search_with_product_result(db, indexed_products,products, _, _ = execute_dashboard_search(admin_client,PHRASE_WITH_RESULTS)assert DASHBOARD_PRODUCTS == products+++EXISTING_EMAIL = '[email protected]'+USERS = {EXISTING_EMAIL: 9}+++def customers(db):+ for email, pk in USERS.items():+ User.objects.create_user(email, 'password', pk=pk)++[email protected](record_mode='once', match_on=MATCH_SEARCH_REQUEST)+def test_dashboard_search_user_by_email(db, admin_client, customers):+ ''' user can be found in dashboard search by email address '''+ _, users, _ = execute_dashboard_search(admin_client, EXISTING_EMAIL)+ assert 1 == len(users)+ assert USERS[EXISTING_EMAIL] in users