Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Split fixtures in the Plugin module (#16891)

Filip Owczarek63825d59621f
diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.py
index 50c3dd9862..282ed203be 100644
--- a/saleor/graphql/checkout/tests/test_checkout.py
+++ b/saleor/graphql/checkout/tests/test_checkout.py
@@ -234,7 +234,7 @@ def test_checkout_available_payment_gateways_currency_specified_USD(
api_client,
checkout_with_item,
expected_dummy_gateway,
- _sample_gateway,
+ sample_gateway,
):
checkout_with_item.currency = "USD"
checkout_with_item.save(update_fields=["currency"])
@@ -253,7 +253,7 @@ def test_checkout_available_payment_gateways_currency_specified_USD(
def test_checkout_available_payment_gateways_currency_specified_EUR(
- api_client, checkout_with_item, expected_dummy_gateway, _sample_gateway
+ api_client, checkout_with_item, expected_dummy_gateway, sample_gateway
):
checkout_with_item.currency = "EUR"
checkout_with_item.save(update_fields=["currency"])
diff --git a/saleor/graphql/shop/tests/queries/test_shop.py b/saleor/graphql/shop/tests/queries/test_shop.py
index 2e7f676c98..2a72ece7c1 100644
--- a/saleor/graphql/shop/tests/queries/test_shop.py
+++ b/saleor/graphql/shop/tests/queries/test_shop.py
@@ -557,9 +557,7 @@ AVAILABLE_PAYMENT_GATEWAYS_QUERY = """
"""
-def test_query_available_payment_gateways(
- user_api_client, _sample_gateway, channel_USD
-):
+def test_query_available_payment_gateways(user_api_client, sample_gateway, channel_USD):
# given
query = AVAILABLE_PAYMENT_GATEWAYS_QUERY
@@ -580,7 +578,7 @@ def test_query_available_payment_gateways(
def test_query_available_payment_gateways_specified_currency_USD(
- user_api_client, _sample_gateway, channel_USD
+ user_api_client, sample_gateway, channel_USD
):
# given
query = AVAILABLE_PAYMENT_GATEWAYS_QUERY
@@ -602,7 +600,7 @@ def test_query_available_payment_gateways_specified_currency_USD(
def test_query_available_payment_gateways_specified_currency_EUR(
- user_api_client, _sample_gateway, channel_USD
+ user_api_client, sample_gateway, channel_USD
):
# given
query = AVAILABLE_PAYMENT_GATEWAYS_QUERY
diff --git a/saleor/plugins/tests/fixtures/__init__.py b/saleor/plugins/tests/fixtures/__init__.py
new file mode 100644
index 0000000000..378c0b141c
--- /dev/null
+++ b/saleor/plugins/tests/fixtures/__init__.py
@@ -0,0 +1,3 @@
+from .gateway import * # noqa: F403
+from .plugin_configuration import * # noqa: F403
+from .plugin_manager import * # noqa: F403
diff --git a/saleor/plugins/tests/fixtures/gateway.py b/saleor/plugins/tests/fixtures/gateway.py
new file mode 100644
index 0000000000..87bb05875b
--- /dev/null
+++ b/saleor/plugins/tests/fixtures/gateway.py
@@ -0,0 +1,18 @@
+import pytest
+
+
[email protected](autouse=True)
+def setup_dummy_gateways(settings):
+ settings.PLUGINS = [
+ "saleor.payment.gateways.dummy.plugin.DummyGatewayPlugin",
+ "saleor.payment.gateways.dummy_credit_card.plugin.DummyCreditCardGatewayPlugin",
+ ]
+ return settings
+
+
+def sample_gateway(settings):
+ settings.PLUGINS += [
+ "saleor.plugins.tests.sample_plugins.ActiveDummyPaymentGateway"
+ ]
+ return settings
diff --git a/saleor/plugins/tests/fixtures.py b/saleor/plugins/tests/fixtures/plugin_configuration.py
similarity index 85%
rename from saleor/plugins/tests/fixtures.py
rename to saleor/plugins/tests/fixtures/plugin_configuration.py
index 88e812a288..8d2d7f3c67 100644
--- a/saleor/plugins/tests/fixtures.py
+++ b/saleor/plugins/tests/fixtures/plugin_configuration.py
@@ -2,11 +2,9 @@ import copy
import pytest
-from ..base_plugin import ConfigurationTypeField
-from ..manager import PluginsManager
-from ..models import PluginConfiguration
-from .sample_plugins import (
- ALL_PLUGINS,
+from ...base_plugin import ConfigurationTypeField
+from ...models import PluginConfiguration
+from ..sample_plugins import (
ChannelPluginSample,
PluginInactive,
PluginSample,
@@ -91,14 +89,3 @@ def new_config():
@pytest.fixture
def new_config_structure():
return {"type": ConfigurationTypeField.STRING, "help_text": "foo", "label": "foo"}
-
-
-def plugins_manager():
- return PluginsManager(plugins=[])
-
-
-def all_plugins_manager():
- plugins_as_module_paths = [p.__module__ + "." + p.__name__ for p in ALL_PLUGINS]
- return PluginsManager(plugins=plugins_as_module_paths)
diff --git a/saleor/plugins/tests/fixtures/plugin_manager.py b/saleor/plugins/tests/fixtures/plugin_manager.py
new file mode 100644
index 0000000000..d125295423
--- /dev/null
+++ b/saleor/plugins/tests/fixtures/plugin_manager.py
@@ -0,0 +1,15 @@
+import pytest
+
+from ...manager import PluginsManager
+from ..sample_plugins import ALL_PLUGINS
+
+
+def plugins_manager():
+ return PluginsManager(plugins=[])
+
+
+def all_plugins_manager():
+ plugins_as_module_paths = [p.__module__ + "." + p.__name__ for p in ALL_PLUGINS]
+ return PluginsManager(plugins=plugins_as_module_paths)
diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.py
index 024811154a..aa397b9d06 100644
--- a/saleor/tests/fixtures.py
+++ b/saleor/tests/fixtures.py
@@ -173,22 +173,6 @@ def assert_max_num_queries(capture_queries):
return partial(capture_queries, exact=False)
[email protected](autouse=True)
-def setup_dummy_gateways(settings):
- settings.PLUGINS = [
- "saleor.payment.gateways.dummy.plugin.DummyGatewayPlugin",
- "saleor.payment.gateways.dummy_credit_card.plugin.DummyCreditCardGatewayPlugin",
- ]
- return settings
-
-
-def _sample_gateway(settings):
- settings.PLUGINS += [
- "saleor.plugins.tests.sample_plugins.ActiveDummyPaymentGateway"
- ]
-
-
@pytest.fixture
def checkout(db, channel_USD, settings):
checkout = Checkout.objects.create(