Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Align integration tests with real communication
Jakub Draganekcfc5f56ccb15
diff --git a/tests/cassettes/test_new_search_doesnt_show_unpublished.yaml b/tests/cassettes/test_new_search_doesnt_show_unpublished.yamlindex c0fed486de..8ec9a6537e 100644--- a/tests/cassettes/test_new_search_doesnt_show_unpublished.yaml+++ b/tests/cassettes/test_new_search_doesnt_show_unpublished.yaml@@ -1,17 +1,17 @@interactions:- request:- body: '{"_source": ["pk"], "query": {"bool": {"must": [{"multi_match": {"fields":- ["name", "description"], "query": "Group"}}], "filter": [{"term": {"is_published_filter":- true}}, {"match": {"content_type": "product.Product"}}]}}}'+ body: '{"query": {"bool": {"must": [{"multi_match": {"query": "Group", "fields":+ ["name", "description"]}}], "filter": [{"term": {"is_published": true}}]}},+ "_source": false}'headers:connection: [keep-alive]content-type: [application/json]method: GET- uri: http://search:9200/storefront__product_product/_search+ uri: http://search:9200/storefront/product_document/_searchresponse:- body: {string: '{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":3,"max_score":3.2280896,"hits":[{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:58","_score":3.2280896,"_source":{"pk":"58"}},{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:15","_score":2.7298274,"_source":{"pk":"15"}},{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:34","_score":2.7298274,"_source":{"pk":"34"}}]}}'}+ body: {string: '{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":2,"max_score":3.223138,"hits":[{"_index":"storefront","_type":"product_document","_id":"15","_score":3.223138},{"_index":"storefront","_type":"product_document","_id":"56","_score":3.223138}]}}'}headers:- content-length: ['531']+ content-length: ['285']content-type: [application/json; charset=UTF-8]status: {code: 200, message: OK}version: 1diff --git a/tests/cassettes/test_new_search_with_empty_results.yaml b/tests/cassettes/test_new_search_with_empty_results.yamlindex fa32dfc2bc..dc6f42fccc 100644--- a/tests/cassettes/test_new_search_with_empty_results.yaml+++ b/tests/cassettes/test_new_search_with_empty_results.yaml@@ -1,17 +1,17 @@interactions:- request:- body: '{"query": {"bool": {"filter": [{"term": {"is_published_filter": true}},- {"match": {"content_type": "product.Product"}}], "must": [{"multi_match": {"query":- "foo", "fields": ["name", "description"]}}]}}, "_source": ["pk"]}'+ body: '{"query": {"bool": {"must": [{"multi_match": {"query": "foo", "fields":+ ["name", "description"]}}], "filter": [{"term": {"is_published": true}}]}},+ "_source": false}'headers:connection: [keep-alive]content-type: [application/json]method: GET- uri: http://search:9200/storefront__product_product/_search+ uri: http://search:9200/storefront/product_document/_searchresponse:- body: {string: '{"took":15,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}+ body: {string: '{"took":0,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}headers:- content-length: ['123']+ content-length: ['122']content-type: [application/json; charset=UTF-8]status: {code: 200, message: OK}version: 1diff --git a/tests/cassettes/test_new_search_with_result.yaml b/tests/cassettes/test_new_search_with_result.yamlindex c8b91750c5..8ec9a6537e 100644--- a/tests/cassettes/test_new_search_with_result.yaml+++ b/tests/cassettes/test_new_search_with_result.yaml@@ -1,17 +1,17 @@interactions:- request:- body: '{"_source": ["pk"], "query": {"bool": {"filter": [{"term": {"is_published_filter":- true}}, {"match": {"content_type": "product.Product"}}], "must": [{"multi_match":- {"query": "Group", "fields": ["name", "description"]}}]}}}'+ body: '{"query": {"bool": {"must": [{"multi_match": {"query": "Group", "fields":+ ["name", "description"]}}], "filter": [{"term": {"is_published": true}}]}},+ "_source": false}'headers:connection: [keep-alive]content-type: [application/json]method: GET- uri: http://search:9200/storefront__product_product/_search+ uri: http://search:9200/storefront/product_document/_searchresponse:- body: {string: '{"took":9,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":3,"max_score":3.2280896,"hits":[{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:58","_score":3.2280896,"_source":{"pk":"58"}},{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:15","_score":2.7298274,"_source":{"pk":"15"}},{"_index":"storefront__product_product","_type":"product_product","_id":"product_product:34","_score":2.7298274,"_source":{"pk":"34"}}]}}'}+ body: {string: '{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":2,"max_score":3.223138,"hits":[{"_index":"storefront","_type":"product_document","_id":"15","_score":3.223138},{"_index":"storefront","_type":"product_document","_id":"56","_score":3.223138}]}}'}headers:- content-length: ['531']+ content-length: ['285']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 2d5c080624..3e6050f94a 100644--- a/tests/test_search.py+++ b/tests/test_search.py@@ -5,8 +5,7 @@ import pytestMATCH_SEARCH_REQUEST = ['method', 'host', 'port', 'path', 'body']-NEW_BACKEND_FOUND = {15, 34, 58} # same as in recorded data!-PRODUCTS_INDEXED = NEW_BACKEND_FOUND+PRODUCTS_INDEXED = {15, 56} # same as in recorded data!@pytest.fixture(scope='function', autouse=True)@@ -57,11 +56,11 @@ def test_new_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 NEW_BACKEND_FOUND == set(found_products)+ assert PRODUCTS_INDEXED == set(found_products)assert EXISTING_PHRASE == response.context['query']-PRODUCTS_TO_UNPUBLISH = {15, 34}+PRODUCTS_TO_UNPUBLISH = {56}@pytest.fixture@@ -77,7 +76,7 @@ def products_with_mixed_publishing(indexed_products):@pytest.mark.vcr(record_mode='once', match_on=MATCH_SEARCH_REQUEST)def test_new_search_doesnt_show_unpublished(db, products_with_mixed_publishing,client):- published_products = NEW_BACKEND_FOUND - PRODUCTS_TO_UNPUBLISH+ published_products = PRODUCTS_INDEXED - PRODUCTS_TO_UNPUBLISHEXISTING_PHRASE = 'Group'response = client.get(reverse('search:search'), {'q': EXISTING_PHRASE})found_products = _extract_pks(response.context['results'].object_list)