Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Record search query with no results
Jakub Draganekbf50766edc52
diff --git a/tests/cassettes/test_index_products.yaml b/tests/cassettes/test_index_products.yamlindex 6dc28e6110..a317426f6a 100644--- a/tests/cassettes/test_index_products.yaml+++ b/tests/cassettes/test_index_products.yaml@@ -453,4 +453,239 @@ interactions:content-length: ['50']content-type: [application/json; charset=UTF-8]status: {code: 200, message: OK}+- request:+ body: '{"settings": {"analysis": {"analyzer": {"edgengram_analyzer": {"type":+ "custom", "tokenizer": "lowercase", "filter": ["asciifolding", "edgengram"]},+ "ngram_analyzer": {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding",+ "ngram"]}}, "tokenizer": {"edgengram_tokenizer": {"type": "edgeNGram", "max_gram":+ 15, "min_gram": 2, "side": "front"}, "ngram_tokenizer": {"type": "nGram", "max_gram":+ 15, "min_gram": 3}}, "filter": {"ngram": {"type": "nGram", "max_gram": 15, "min_gram":+ 3}, "edgengram": {"type": "edgeNGram", "max_gram": 15, "min_gram": 1}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user+ response:+ body: {string: '{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/kskhjtSkTtGsOltOEkgl8Q] already exists","index_uuid":"kskhjtSkTtGsOltOEkgl8Q","index":"storefront__userprofile_user"}],"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/kskhjtSkTtGsOltOEkgl8Q] already exists","index_uuid":"kskhjtSkTtGsOltOEkgl8Q","index":"storefront__userprofile_user"},"status":400}'}+ headers:+ content-length: ['447']+ content-type: [application/json; charset=UTF-8]+ status: {code: 400, message: Bad Request}+- request:+ body: '{"settings": {"analysis": {"filter": {"edgengram": {"min_gram": 1, "type":+ "edgeNGram", "max_gram": 15}, "ngram": {"min_gram": 3, "type": "nGram", "max_gram":+ 15}}, "tokenizer": {"edgengram_tokenizer": {"min_gram": 2, "side": "front",+ "type": "edgeNGram", "max_gram": 15}, "ngram_tokenizer": {"min_gram": 3, "type":+ "nGram", "max_gram": 15}}, "analyzer": {"edgengram_analyzer": {"filter": ["asciifolding",+ "edgengram"], "tokenizer": "lowercase", "type": "custom"}, "ngram_analyzer":+ {"filter": ["asciifolding", "ngram"], "tokenizer": "lowercase", "type": "custom"}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user+ response:+ body: {string: '{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"}],"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"},"status":400}'}+ headers:+ content-length: ['447']+ content-type: [application/json; charset=UTF-8]+ status: {code: 400, message: Bad Request}+- request:+ body: '{"settings": {"analysis": {"analyzer": {"edgengram_analyzer": {"type":+ "custom", "tokenizer": "lowercase", "filter": ["asciifolding", "edgengram"]},+ "ngram_analyzer": {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding",+ "ngram"]}}, "tokenizer": {"ngram_tokenizer": {"type": "nGram", "max_gram": 15,+ "min_gram": 3}, "edgengram_tokenizer": {"type": "edgeNGram", "max_gram": 15,+ "side": "front", "min_gram": 2}}, "filter": {"edgengram": {"type": "edgeNGram",+ "max_gram": 15, "min_gram": 1}, "ngram": {"type": "nGram", "max_gram": 15, "min_gram":+ 3}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user+ response:+ body: {string: '{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"}],"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"},"status":400}'}+ headers:+ content-length: ['447']+ content-type: [application/json; charset=UTF-8]+ status: {code: 400, message: Bad Request}+- request:+ body: '{"settings": {"analysis": {"filter": {"ngram": {"min_gram": 3, "type":+ "nGram", "max_gram": 15}, "edgengram": {"min_gram": 1, "type": "edgeNGram",+ "max_gram": 15}}, "analyzer": {"ngram_analyzer": {"filter": ["asciifolding",+ "ngram"], "tokenizer": "lowercase", "type": "custom"}, "edgengram_analyzer":+ {"filter": ["asciifolding", "edgengram"], "tokenizer": "lowercase", "type":+ "custom"}}, "tokenizer": {"edgengram_tokenizer": {"min_gram": 2, "type": "edgeNGram",+ "side": "front", "max_gram": 15}, "ngram_tokenizer": {"min_gram": 3, "type":+ "nGram", "max_gram": 15}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user+ response:+ body: {string: '{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"}],"type":"index_already_exists_exception","reason":"index+ [storefront__userprofile_user/DIb6VIR2RB-UZBYhQ0OKwA] already exists","index_uuid":"DIb6VIR2RB-UZBYhQ0OKwA","index":"storefront__userprofile_user"},"status":400}'}+ headers:+ content-length: ['447']+ content-type: [application/json; charset=UTF-8]+ status: {code: 400, message: Bad Request}+- request:+ body: '{"settings": {"analysis": {"tokenizer": {"edgengram_tokenizer": {"side":+ "front", "type": "edgeNGram", "max_gram": 15, "min_gram": 2}, "ngram_tokenizer":+ {"type": "nGram", "max_gram": 15, "min_gram": 3}}, "analyzer": {"edgengram_analyzer":+ {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding", "edgengram"]},+ "ngram_analyzer": {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding",+ "ngram"]}}, "filter": {"edgengram": {"type": "edgeNGram", "max_gram": 15, "min_gram":+ 1}, "ngram": {"type": "nGram", "max_gram": 15, "min_gram": 3}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user+ response:+ body: {string: '{"acknowledged":true,"shards_acknowledged":true}'}+ headers:+ content-length: ['48']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"userprofile_user": {"properties": {"email": {"include_in_all": true,+ "type": "text"}, "_partials": {"include_in_all": false, "type": "text", "analyzer":+ "edgengram_analyzer", "search_analyzer": "standard"}, "content_type": {"include_in_all":+ false, "type": "keyword"}, "pk": {"include_in_all": false, "type": "keyword",+ "store": true}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__userprofile_user/_mapping/userprofile_user?update_all_types=true+ response:+ body: {string: '{"acknowledged":true}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "field [include_in_all] is deprecated,+ as [_all] is deprecated, and will be disallowed in 6.0, use [copy_to] instead."+ "Mon, 16 Oct 2017 15:04:32 GMT"']+ content-length: ['21']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"settings": {"analysis": {"tokenizer": {"edgengram_tokenizer": {"side":+ "front", "type": "edgeNGram", "max_gram": 15, "min_gram": 2}, "ngram_tokenizer":+ {"type": "nGram", "max_gram": 15, "min_gram": 3}}, "analyzer": {"edgengram_analyzer":+ {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding", "edgengram"]},+ "ngram_analyzer": {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding",+ "ngram"]}}, "filter": {"edgengram": {"type": "edgeNGram", "max_gram": 15, "min_gram":+ 1}, "ngram": {"type": "nGram", "max_gram": 15, "min_gram": 3}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__product_product+ response:+ body: {string: '{"acknowledged":true,"shards_acknowledged":true}'}+ headers:+ content-length: ['48']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"product_product": {"properties": {"name": {"include_in_all": true, "type":+ "text", "analyzer": "edgengram_analyzer", "search_analyzer": "standard"}, "available_on_filter":+ {"include_in_all": false, "type": "date"}, "content_type": {"include_in_all":+ false, "type": "keyword"}, "pk": {"include_in_all": false, "type": "keyword",+ "store": true}, "is_published_filter": {"include_in_all": false, "type": "boolean"},+ "description": {"include_in_all": true, "type": "text"}, "_partials": {"include_in_all":+ false, "type": "text", "analyzer": "edgengram_analyzer", "search_analyzer":+ "standard"}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__product_product/_mapping/product_product?update_all_types=true+ response:+ body: {string: '{"acknowledged":true}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "field [include_in_all] is deprecated,+ as [_all] is deprecated, and will be disallowed in 6.0, use [copy_to] instead."+ "Mon, 16 Oct 2017 15:04:32 GMT"']+ content-length: ['21']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"index": {"_id": "product_product:1", "_index": "storefront__product_product",+ "_type": "product_product"}}++ {"pk": "1", "description": "", "is_published_filter": true, "available_on_filter":+ null, "_partials": ["Test product 1"], "name": "Test product 1", "content_type":+ ["product.Product"]}++ {"index": {"_id": "product_product:2", "_index": "storefront__product_product",+ "_type": "product_product"}}++ {"pk": "2", "description": "", "is_published_filter": true, "available_on_filter":+ null, "_partials": ["Test product 2"], "name": "Test product 2", "content_type":+ ["product.Product"]}++'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: POST+ uri: http://search:9200/_bulk+ response:+ body: {string: '{"took":127,"errors":false,"items":[{"index":{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true,"status":201}},{"index":{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:2","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true,"status":201}}]}'}+ headers:+ content-length: ['459']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"settings": {"analysis": {"tokenizer": {"edgengram_tokenizer": {"side":+ "front", "type": "edgeNGram", "max_gram": 15, "min_gram": 2}, "ngram_tokenizer":+ {"type": "nGram", "max_gram": 15, "min_gram": 3}}, "analyzer": {"edgengram_analyzer":+ {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding", "edgengram"]},+ "ngram_analyzer": {"type": "custom", "tokenizer": "lowercase", "filter": ["asciifolding",+ "ngram"]}}, "filter": {"edgengram": {"type": "edgeNGram", "max_gram": 15, "min_gram":+ 1}, "ngram": {"type": "nGram", "max_gram": 15, "min_gram": 3}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__order_order+ response:+ body: {string: '{"acknowledged":true,"shards_acknowledged":true}'}+ headers:+ content-length: ['48']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"order_order": {"properties": {"_index_shipping_phone": {"include_in_all":+ true, "type": "text"}, "content_type": {"include_in_all": false, "type": "keyword"},+ "pk": {"include_in_all": false, "type": "keyword", "store": true}, "_index_billing_phone":+ {"include_in_all": true, "type": "text"}, "get_user_current_email": {"include_in_all":+ true, "type": "text"}, "_partials": {"include_in_all": false, "type": "text",+ "analyzer": "edgengram_analyzer", "search_analyzer": "standard"}, "id": {"include_in_all":+ true, "type": "integer"}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: PUT+ uri: http://search:9200/storefront__order_order/_mapping/order_order?update_all_types=true+ response:+ body: {string: '{"acknowledged":true}'}+ headers:+ Warning: ['299 Elasticsearch-5.4.3-eed30a8 "field [include_in_all] is deprecated,+ as [_all] is deprecated, and will be disallowed in 6.0, use [copy_to] instead."+ "Mon, 16 Oct 2017 15:04:33 GMT"']+ content-length: ['21']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}version: 1diff --git a/tests/cassettes/test_search_with_empty_result.yaml b/tests/cassettes/test_search_with_empty_result.yamlnew file mode 100644index 0000000000..6a53ca002d--- /dev/null+++ b/tests/cassettes/test_search_with_empty_result.yaml@@ -0,0 +1,36 @@+interactions:+- request:+ body: '{"query": {"bool": {"must": {"multi_match": {"fields": ["_all", "_partials"],+ "query": "foo"}}, "filter": [{"match": {"content_type": "product.Product"}},+ {"bool": {"must": [{"bool": {"should": [{"range": {"available_on_filter": {"lte":+ "2017-10-16"}}}, {"bool": {"must_not": {"term": {"field": "available_on_filter"}}}}]}},+ {"term": {"is_published_filter": true}}]}}]}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: GET+ uri: http://search:9200/storefront__product_product/_search?from=0&_source=pk+ response:+ body: {string: '{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}+ headers:+ content-length: ['122']+ content-type: [application/json; charset=UTF-8]+ status: {code: 200, message: OK}+- request:+ body: '{"query": {"bool": {"filter": [{"match": {"content_type": "product.Product"}},+ {"bool": {"must": [{"bool": {"should": [{"range": {"available_on_filter": {"lte":+ "2017-10-16"}}}, {"bool": {"must_not": {"term": {"field": "available_on_filter"}}}}]}},+ {"term": {"is_published_filter": true}}]}}], "must": {"multi_match": {"fields":+ ["_all", "_partials"], "query": "foo"}}}}}'+ headers:+ connection: [keep-alive]+ content-type: [application/json]+ method: GET+ uri: http://search:9200/storefront__product_product/_search?_source=pk&from=0+ response:+ body: {string: '{"took":113,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}+ headers:+ content-length: ['124']+ 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 fc33318962..bf5acc7e80 100644--- a/tests/test_search.py+++ b/tests/test_search.py@@ -1,9 +1,18 @@from django.core.management import call_command+from django.core.urlresolvers import reverseimport pytest@pytest.mark.integration@pytest.mark.vcr(record_mode='once')def test_index_products(product_list):- call_command('update_index')+ options = {'backend_name': 'default'}+ call_command('update_index', **options)++ record_mode='once', match_on=['url', 'method', 'body'])+def test_search_with_empty_result(db, client):+ WORD = 'foo'+ client.get(reverse('search:search'), {'q': WORD})