Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move sample plugins to one place
Mira Szewczyk335e409676ec
diff --git a/tests/api/test_extensions.py b/tests/api/test_extensions.pyindex 1fed1f2f7b..2a63027d9a 100644--- a/tests/api/test_extensions.py+++ b/tests/api/test_extensions.py@@ -6,45 +6,7 @@ from saleor.extensions.base_plugin import BasePluginfrom saleor.extensions.manager import get_extensions_managerfrom saleor.extensions.models import PluginConfigurationfrom tests.api.utils import get_graphql_content-from tests.extensions.helpers import get_config_value---class PluginSample(BasePlugin):- PLUGIN_NAME = "PluginSample"- CONFIG_STRUCTURE = {- "Username": {- "type": ConfigurationTypeField.STRING,- "help_text": "Username input field",- "label": "Username",- },- "Password": {- "type": ConfigurationTypeField.STRING,- "help_text": "Password input field",- "label": "Password",- },- "Use sandbox": {- "type": ConfigurationTypeField.BOOLEAN,- "help_text": "Use sandbox",- "label": "Use sandbox",- },- }-- @classmethod- def get_plugin_configuration(cls, queryset) -> "PluginConfiguration":- qs = queryset.filter(name="PluginSample")- if qs.exists():- return qs[0]- defaults = {- "name": "PluginSample",- "description": "Test plugin description",- "active": True,- "configuration": [- {"name": "Username", "value": "admin"},- {"name": "Password", "value": "123"},- {"name": "Use sandbox", "value": False},- ],- }- return PluginConfiguration.objects.create(**defaults)+from tests.extensions.helpers import PluginSample, get_config_valuedef test_query_plugin_configurations(@@ -52,7 +14,7 @@ def test_query_plugin_configurations():# Enable test plugin- settings.PLUGINS = ["tests.api.test_extensions.PluginSample"]+ settings.PLUGINS = ["tests.extensions.helpers.PluginSample"]query = """{plugins(first:1){diff --git a/tests/extensions/helpers.py b/tests/extensions/helpers.pyindex e03462fa26..563e005b69 100644--- a/tests/extensions/helpers.py+++ b/tests/extensions/helpers.py@@ -1,5 +1,8 @@from typing import TYPE_CHECKING, Union+from saleor.extensions import ConfigurationTypeField+from saleor.extensions.base_plugin import BasePlugin+if TYPE_CHECKING:from saleor.extensions import ConfigurationType@@ -10,3 +13,37 @@ def get_config_value(for elem in configuration:if elem["name"] == field_name:return elem["value"]+++class PluginSample(BasePlugin):+ PLUGIN_NAME = "PluginSample"+ CONFIG_STRUCTURE = {+ "Username": {+ "type": ConfigurationTypeField.STRING,+ "help_text": "Username input field",+ "label": "Username",+ },+ "Password": {+ "type": ConfigurationTypeField.STRING,+ "help_text": "Password input field",+ "label": "Password",+ },+ "Use sandbox": {+ "type": ConfigurationTypeField.BOOLEAN,+ "help_text": "Use sandbox",+ "label": "Use sandbox",+ },+ }++ @classmethod+ def _get_default_configuration(cls):+ return {+ "name": "PluginSample",+ "description": "Test plugin description",+ "active": True,+ "configuration": [+ {"name": "Username", "value": "admin"},+ {"name": "Password", "value": "123"},+ {"name": "Use sandbox", "value": False},+ ],+ }