Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move hardcoded values in tests to fixtures for future reuse
Jakub Draganekbe38e647d857
diff --git a/saleor/search/backends/test_newelastic.py b/saleor/search/backends/test_newelastic.pyindex 9dc715edf8..5ca0d92919 100644--- a/saleor/search/backends/test_newelastic.py+++ b/saleor/search/backends/test_newelastic.py@@ -1,18 +1,28 @@from . import newelastic+import pytest-def test_search(mocker):- mocker.patch.object(newelastic.CLIENT, 'search', returnvalue=[])- phrase = 'foo'- products = newelastic.search(phrase)- expected_query = {+def search_phrase():+ return 'How fortunate man with none'+++def es_search_query(search_phrase):+ query = {'query': {'multi_match': {'fields': ['name', 'description'],- 'query': phrase+ 'query': search_phrase}}}+ return query+++def test_no_result_search(mocker, es_search_query, search_phrase):+ mocker.patch.object(newelastic.CLIENT, 'search', returnvalue=[])+ products = newelastic.search(search_phrase)newelastic.CLIENT.search.assert_called_once_with(- body=expected_query, doc_type=[], index=None)+ body=es_search_query, doc_type=[], index=None)assert not products