Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add dashboard backend picking
Jakub Draganek23b0a1913d91
diff --git a/saleor/search/backends/picker.py b/saleor/search/backends/picker.pyindex 7565fcb7f1..2a84b90ee8 100644--- a/saleor/search/backends/picker.py+++ b/saleor/search/backends/picker.py@@ -1,10 +1,21 @@from __future__ import unicode_literalsfrom django.conf import settings-from . import elasticsearch, postgresql+from . import (elasticsearch, elasticsearch_dashboard, postgresql,+ postgresql_dashboard)+++def elastic_configured():+ return settings.ELASTICSEARCH_URL and not settings.PREFER_DB_SEARCHdef pick_backend():- if settings.ELASTICSEARCH_URL and not settings.PREFER_DB_SEARCH:+ if elastic_configured():return elasticsearch.searchreturn postgresql.search+++def pick_dashboard_backend():+ if elastic_configured():+ return elasticsearch_dashboard.search+ return postgresql_dashboard.searchdiff --git a/saleor/search/backends/postgresql_dashboard.py b/saleor/search/backends/postgresql_dashboard.pynew file mode 100644index 0000000000..e11b196206--- /dev/null+++ b/saleor/search/backends/postgresql_dashboard.py@@ -0,0 +1,2 @@+def search(phrase):+ passdiff --git a/saleor/search/backends/test_picker.py b/saleor/search/backends/test_picker.pyindex f45c5f9d64..40bac6fb22 100644--- a/saleor/search/backends/test_picker.py+++ b/saleor/search/backends/test_picker.py@@ -1,21 +1,31 @@from __future__ import unicode_literals-from .picker import pick_backend-from . import postgresql, elasticsearch+from .picker import pick_backend, pick_dashboard_backend+from . import (postgresql, postgresql_dashboard, elasticsearch_dashboard,+ elasticsearch)+++POSTGRES_STOREFRONT_BACKEND = postgresql.search+POSTGRES_DASHBOARD_BACKEND = postgresql_dashboard.search+ELASTIC_STOREFRONT_BACKEND = elasticsearch.search+ELASTIC_DASHBOARD_BACKEND = elasticsearch_dashboard.searchdef test_picks_db(settings):settings.ELASTICSEARCH_URL = None- assert pick_backend() is postgresql.search+ assert pick_backend() is POSTGRES_STOREFRONT_BACKEND+ assert pick_dashboard_backend() is POSTGRES_DASHBOARD_BACKENDdef test_pick_elastic_when_configured(settings):settings.ELASTICSEARCH_URL = 'whatever'settings.PREFER_DB_SEARCH = False- assert pick_backend() is elasticsearch.search+ assert pick_backend() is ELASTIC_STOREFRONT_BACKEND+ assert pick_dashboard_backend() is ELASTIC_DASHBOARD_BACKENDdef test_pick_db_when_preferred(settings):settings.ELASTICSEARCH = 'whatever'settings.PREFER_DB_SEARCH = True- assert pick_backend() is postgresql.search+ assert pick_backend() is POSTGRES_STOREFRONT_BACKEND+ assert pick_dashboard_backend() is POSTGRES_DASHBOARD_BACKEND