Skip to content

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

Cleanup test and api

Damian Wysocki33e1e5784107
diff --git a/saleor/graphql/core/enums.py b/saleor/graphql/core/enums.py
index 1873dc86f8..5b568017cd 100644
--- a/saleor/graphql/core/enums.py
+++ b/saleor/graphql/core/enums.py
@@ -6,12 +6,13 @@ from ...core import error_codes as core_error_codes
from ...core.permissions import get_permissions_enum_list
from ...core.weight import WeightUnits
from ...discount import error_codes as discount_error_codes
-from ...plugins import error_codes as plugins_error_codes, TaxRateType as CoreTaxRateType
from ...giftcard import error_codes as giftcard_error_codes
from ...menu import error_codes as menu_error_codes
from ...order import error_codes as order_error_codes
from ...page import error_codes as page_error_codes
from ...payment import error_codes as payment_error_codes
+from ...plugins import error_codes as plugins_error_codes
+from ...plugins.vatlayer.plugin import TaxRateType as CoreTaxRateType
from ...product import error_codes as product_error_codes
from ...shipping import error_codes as shipping_error_codes
from ...warehouse import error_codes as warehouse_error_codes
@@ -86,9 +87,7 @@ WeightUnitsEnum = graphene.Enum(
AccountErrorCode = graphene.Enum.from_enum(account_error_codes.AccountErrorCode)
CheckoutErrorCode = graphene.Enum.from_enum(checkout_error_codes.CheckoutErrorCode)
DiscountErrorCode = graphene.Enum.from_enum(discount_error_codes.DiscountErrorCode)
-PluginsErrorCode = graphene.Enum.from_enum(
- plugins_error_codes.PluginsErrorCode
-)
+PluginsErrorCode = graphene.Enum.from_enum(plugins_error_codes.PluginsErrorCode)
GiftCardErrorCode = graphene.Enum.from_enum(giftcard_error_codes.GiftCardErrorCode)
MenuErrorCode = graphene.Enum.from_enum(menu_error_codes.MenuErrorCode)
MetadataErrorCode = graphene.Enum.from_enum(core_error_codes.MetadataErrorCode)
diff --git a/saleor/graphql/plugins/enums.py b/saleor/graphql/plugins/enums.py
index eab67f71e6..f6b2510cae 100644
--- a/saleor/graphql/plugins/enums.py
+++ b/saleor/graphql/plugins/enums.py
@@ -1,4 +1,4 @@
-from ...plugins import ConfigurationTypeField
from ...graphql.core.enums import to_enum
+from ...plugins.base_plugin import ConfigurationTypeField
ConfigurationTypeFieldEnum = to_enum(ConfigurationTypeField)
diff --git a/saleor/graphql/plugins/filters.py b/saleor/graphql/plugins/filters.py
index f6eeba231e..36c57bba7f 100644
--- a/saleor/graphql/plugins/filters.py
+++ b/saleor/graphql/plugins/filters.py
@@ -4,7 +4,7 @@ import graphene
if TYPE_CHECKING:
# flake8: noqa
- from ...plugins import BasePlugin
+ from ...plugins.base_plugin import BasePlugin
def filter_plugin_search(
diff --git a/saleor/graphql/plugins/resolvers.py b/saleor/graphql/plugins/resolvers.py
index 91ff97ff4f..86df92d43a 100644
--- a/saleor/graphql/plugins/resolvers.py
+++ b/saleor/graphql/plugins/resolvers.py
@@ -1,4 +1,4 @@
-from ...plugins import BasePlugin
+from ...plugins.base_plugin import BasePlugin
from ...plugins.manager import get_plugins_manager
from ...plugins.models import PluginConfiguration
from .filters import filter_plugin_search
diff --git a/saleor/graphql/plugins/sorters.py b/saleor/graphql/plugins/sorters.py
index 66ba8bcb35..522494b2ad 100644
--- a/saleor/graphql/plugins/sorters.py
+++ b/saleor/graphql/plugins/sorters.py
@@ -6,7 +6,7 @@ from ..core.types import SortInputObjectType
if TYPE_CHECKING:
# flake8: noqa
- from ...plugins import BasePlugin
+ from ...plugins.base_plugin import BasePlugin
def sort_plugins(
diff --git a/saleor/graphql/plugins/types.py b/saleor/graphql/plugins/types.py
index 27be7781e6..ca79e7a544 100644
--- a/saleor/graphql/plugins/types.py
+++ b/saleor/graphql/plugins/types.py
@@ -2,7 +2,8 @@ from typing import TYPE_CHECKING, Optional
import graphene
-from ...plugins import ConfigurationTypeField, manager, models
+from ...plugins import manager, models
+from ...plugins.base_plugin import ConfigurationTypeField
from ..core.connection import CountableDjangoObjectType
from .enums import ConfigurationTypeFieldEnum
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 2fdd1ee4f1..5f6824d232 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -1625,21 +1625,6 @@ type Error {
message: String
}
-type PluginsError {
- field: String
- message: String
- code: PluginsErrorCode!
-}
-
-enum PluginsErrorCode {
- GRAPHQL_ERROR
- INVALID
- PLUGIN_MISCONFIGURED
- NOT_FOUND
- REQUIRED
- UNIQUE
-}
-
type Fulfillment implements Node & ObjectWithMetadata {
id: ID!
fulfillmentOrder: Int!
@@ -3133,6 +3118,21 @@ input PluginUpdateInput {
configuration: [ConfigurationItemInput]
}
+type PluginsError {
+ field: String
+ message: String
+ code: PluginsErrorCode!
+}
+
+enum PluginsErrorCode {
+ GRAPHQL_ERROR
+ INVALID
+ PLUGIN_MISCONFIGURED
+ NOT_FOUND
+ REQUIRED
+ UNIQUE
+}
+
input PriceRangeInput {
gte: Float
lte: Float
diff --git a/saleor/payment/gateways/braintree/plugin.py b/saleor/payment/gateways/braintree/plugin.py
index 2d56c248d5..d8a550b76e 100644
--- a/saleor/payment/gateways/braintree/plugin.py
+++ b/saleor/payment/gateways/braintree/plugin.py
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING, List
-from saleor.plugins import ConfigurationTypeField, BasePlugin
+from saleor.plugins.base_plugin import BasePlugin, ConfigurationTypeField
from . import (
GatewayConfig,
diff --git a/saleor/payment/gateways/dummy/plugin.py b/saleor/payment/gateways/dummy/plugin.py
index 3f7f2b1986..e60c77ad53 100644
--- a/saleor/payment/gateways/dummy/plugin.py
+++ b/saleor/payment/gateways/dummy/plugin.py
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
-from saleor.plugins import ConfigurationTypeField, BasePlugin
+from saleor.plugins.base_plugin import BasePlugin, ConfigurationTypeField
from . import (
GatewayConfig,
diff --git a/saleor/payment/gateways/razorpay/plugin.py b/saleor/payment/gateways/razorpay/plugin.py
index a6a72367c8..919f0bd4a6 100644
--- a/saleor/payment/gateways/razorpay/plugin.py
+++ b/saleor/payment/gateways/razorpay/plugin.py
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
-from saleor.plugins import ConfigurationTypeField, BasePlugin
+from saleor.plugins.base_plugin import BasePlugin, ConfigurationTypeField
from . import GatewayConfig, capture, process_payment, refund
diff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.py
index 9777f25d5c..e90f1cedbc 100644
--- a/saleor/payment/gateways/stripe/plugin.py
+++ b/saleor/payment/gateways/stripe/plugin.py
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING, List
-from saleor.plugins import ConfigurationTypeField, BasePlugin
+from saleor.plugins.base_plugin import BasePlugin, ConfigurationTypeField
from . import (
GatewayConfig,
diff --git a/saleor/plugins/__init__.py b/saleor/plugins/__init__.py
index 46bc1d1e7e..d2990436ea 100644
--- a/saleor/plugins/__init__.py
+++ b/saleor/plugins/__init__.py
@@ -3,12 +3,6 @@ from typing import List
from .checks import check_plugins # NOQA: F401
-from .base_plugin import BasePlugin, ConfigurationTypeField
-from .anonymize.plugin import AnonymizePlugin
-from .avatax.plugin import AvataxPlugin
-from .vatlayer.plugin import VatlayerPlugin
-from .webhook.plugin import WebhookPlugin
-
def discover_plugins_modules(plugins: List[str]):
plugins_modules = []
diff --git a/saleor/plugins/webhook/__init__.py b/saleor/plugins/webhook/__init__.py
index 1f7e83211b..2a1f6c97b7 100644
--- a/saleor/plugins/webhook/__init__.py
+++ b/saleor/plugins/webhook/__init__.py
@@ -2,7 +2,7 @@ import hashlib
import hmac
from typing import Optional
-from ....site.models import Site
+from ...site.models import Site
def create_hmac_signature(body: str, secret_key: str, encoding: str):
diff --git a/saleor/plugins/webhook/tasks.py b/saleor/plugins/webhook/tasks.py
index 6b12f1b95a..db13ff71e5 100644
--- a/saleor/plugins/webhook/tasks.py
+++ b/saleor/plugins/webhook/tasks.py
@@ -3,9 +3,9 @@ import logging
import requests
from requests.exceptions import RequestException
-from ....celeryconf import app
-from ....webhook.event_types import WebhookEventType
-from ....webhook.models import Webhook
+from ...celeryconf import app
+from ...webhook.event_types import WebhookEventType
+from ...webhook.models import Webhook
from . import create_webhook_headers
logger = logging.getLogger(__name__)
diff --git a/tests/api/test_extensions.py b/tests/api/test_plugins.py
similarity index 98%
rename from tests/api/test_extensions.py
rename to tests/api/test_plugins.py
index a4e3504b65..3df869092d 100644
--- a/tests/api/test_extensions.py
+++ b/tests/api/test_plugins.py
@@ -1,7 +1,8 @@
import copy
+
import pytest
-from saleor.plugins import ConfigurationTypeField
+from saleor.plugins.base_plugin import ConfigurationTypeField
from saleor.plugins.error_codes import PluginsErrorCode
from saleor.plugins.manager import get_plugins_manager
from saleor.plugins.models import PluginConfiguration
@@ -42,7 +43,7 @@ PLUGINS_QUERY = """
def test_query_plugin_configurations(staff_api_client_can_manage_plugins, settings):
# Enable test plugin
- settings.PLUGINS = ["tests.api.plugins.PluginSample"]
+ settings.PLUGINS = ["tests.plugins.sample_plugins.PluginSample"]
response = staff_api_client_can_manage_plugins.post_graphql(PLUGINS_QUERY)
content = get_graphql_content(response)
@@ -96,7 +97,7 @@ def test_query_plugins_hides_secret_fields(
settings,
):
- settings.PLUGINS = ["tests.api.plugins.PluginSample"]
+ settings.PLUGINS = ["tests.plugins.sample_plugins.PluginSample"]
manager = get_plugins_manager()
plugin = manager.get_plugin(PluginSample.PLUGIN_NAME)
configuration = copy.deepcopy(plugin.configuration)
@@ -125,7 +126,7 @@ def test_query_plugins_hides_secret_fields(
def test_query_plugin_configurations_as_customer_user(user_api_client, settings):
- settings.PLUGINS = ["tests.api.plugins.PluginSample"]
+ settings.PLUGINS = ["tests.plugins.sample_plugins.PluginSample"]
response = user_api_client.post_graphql(PLUGINS_QUERY)
assert_no_permission(response)
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
index 4bac1bdbe4..51f0a5a516 100644
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -12,9 +12,9 @@ from graphql_relay import to_global_id
from prices import Money
from saleor.core.taxes import TaxType
-from saleor.plugins.manager import PluginsManager
from saleor.graphql.core.enums import ReportingPeriod
from saleor.graphql.product.utils import create_stocks
+from saleor.plugins.manager import PluginsManager
from saleor.product import AttributeInputType
from saleor.product.error_codes import ProductErrorCode
from saleor.product.models import (
@@ -2097,7 +2097,7 @@ def test_product_type_create_mutation(
staff_api_client, product_type, permission_manage_products, monkeypatch, settings
):
settings.VATLAYER_ACCESS_KEY = "test"
- settings.PLUGINS = ["saleor.plugins.plugins.vatlayer.plugin.VatlayerPlugin"]
+ settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
manager = PluginsManager(plugins=settings.PLUGINS)
query = """
mutation createProductType(
diff --git a/tests/extensions/__init__.py b/tests/plugins/__init__.py
similarity index 100%
rename from tests/extensions/__init__.py
rename to tests/plugins/__init__.py
diff --git a/tests/extensions/conftest.py b/tests/plugins/conftest.py
similarity index 88%
rename from tests/extensions/conftest.py
rename to tests/plugins/conftest.py
index d3970919cd..ce48d9a722 100644
--- a/tests/extensions/conftest.py
+++ b/tests/plugins/conftest.py
@@ -1,8 +1,8 @@
import pytest
-from saleor.plugins import ConfigurationTypeField
+from saleor.plugins.base_plugin import ConfigurationTypeField
from saleor.plugins.models import PluginConfiguration
-from tests.pliugins.sample_plugins import PluginInactive, PluginSample
+from tests.plugins.sample_plugins import PluginInactive, PluginSample
@pytest.fixture
diff --git a/tests/extensions/plugins/__init__.py b/tests/plugins/plugins/__init__.py
similarity index 100%
rename from tests/extensions/plugins/__init__.py
rename to tests/plugins/plugins/__init__.py
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[False-24.39-30.00-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[False-30.00-36.90-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[True-12.20-15.00-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_line_total[True-15.00-18.45-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_shipping.yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_shipping.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_shipping.yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_shipping.yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[False-40.65-50.00-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[False-50.00-61.50-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[True-20.33-25.00-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_subtotal[True-25.00-30.75-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-29.52-37.00-3.0-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-37.00-37.00-3.0-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-40.00-40.00-0.0-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[False-40.00-49.20-0.0-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.00-20.00-5.0-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.00-25.75-5.0-False].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml b/tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml
rename to tests/plugins/plugins/cassettes/test_calculate_checkout_total[True-20.33-25.00-0.0-True].yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_order_line_unit.yaml b/tests/plugins/plugins/cassettes/test_calculate_order_line_unit.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_order_line_unit.yaml
rename to tests/plugins/plugins/cassettes/test_calculate_order_line_unit.yaml
diff --git a/tests/extensions/plugins/cassettes/test_calculate_order_shipping.yaml b/tests/plugins/plugins/cassettes/test_calculate_order_shipping.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_calculate_order_shipping.yaml
rename to tests/plugins/plugins/cassettes/test_calculate_order_shipping.yaml
diff --git a/tests/extensions/plugins/cassettes/test_get_cached_tax_codes_or_fetch.yaml b/tests/plugins/plugins/cassettes/test_get_cached_tax_codes_or_fetch.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_get_cached_tax_codes_or_fetch.yaml
rename to tests/plugins/plugins/cassettes/test_get_cached_tax_codes_or_fetch.yaml
diff --git a/tests/extensions/plugins/cassettes/test_get_cached_tax_codes_or_fetch_wrong_response.yaml b/tests/plugins/plugins/cassettes/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
rename to tests/plugins/plugins/cassettes/test_get_cached_tax_codes_or_fetch_wrong_response.yaml
diff --git a/tests/extensions/plugins/cassettes/test_plugin_uses_configuration_from_db.yaml b/tests/plugins/plugins/cassettes/test_plugin_uses_configuration_from_db.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_plugin_uses_configuration_from_db.yaml
rename to tests/plugins/plugins/cassettes/test_plugin_uses_configuration_from_db.yaml
diff --git a/tests/extensions/plugins/cassettes/test_preprocess_order_creation.yaml b/tests/plugins/plugins/cassettes/test_preprocess_order_creation.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_preprocess_order_creation.yaml
rename to tests/plugins/plugins/cassettes/test_preprocess_order_creation.yaml
diff --git a/tests/extensions/plugins/cassettes/test_preprocess_order_creation_wrong_data.yaml b/tests/plugins/plugins/cassettes/test_preprocess_order_creation_wrong_data.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_preprocess_order_creation_wrong_data.yaml
rename to tests/plugins/plugins/cassettes/test_preprocess_order_creation_wrong_data.yaml
diff --git a/tests/extensions/plugins/cassettes/test_trigger_webhooks_for_event.yaml b/tests/plugins/plugins/cassettes/test_trigger_webhooks_for_event.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_trigger_webhooks_for_event.yaml
rename to tests/plugins/plugins/cassettes/test_trigger_webhooks_for_event.yaml
diff --git a/tests/extensions/plugins/cassettes/test_trigger_webhooks_for_event_with_secret_key.yaml b/tests/plugins/plugins/cassettes/test_trigger_webhooks_for_event_with_secret_key.yaml
similarity index 100%
rename from tests/extensions/plugins/cassettes/test_trigger_webhooks_for_event_with_secret_key.yaml
rename to tests/plugins/plugins/cassettes/test_trigger_webhooks_for_event_with_secret_key.yaml
diff --git a/tests/extensions/plugins/conftest.py b/tests/plugins/plugins/conftest.py
similarity index 100%
rename from tests/extensions/plugins/conftest.py
rename to tests/plugins/plugins/conftest.py
diff --git a/tests/extensions/plugins/test_avatax.py b/tests/plugins/plugins/test_avatax.py
similarity index 93%
rename from tests/extensions/plugins/test_avatax.py
rename to tests/plugins/plugins/test_avatax.py
index ff862ab8da..813511cf81 100644
--- a/tests/extensions/plugins/test_avatax.py
+++ b/tests/plugins/plugins/test_avatax.py
@@ -6,15 +6,15 @@ from prices import Money, TaxedMoney
from saleor.checkout.utils import add_variant_to_checkout
from saleor.core.taxes import TaxError, quantize_price
-from saleor.plugins.manager import get_plugins_manager
-from saleor.plugins.models import PluginConfiguration
from saleor.plugins.avatax import (
AvataxConfiguration,
checkout_needs_new_fetch,
generate_request_data_from_checkout,
get_cached_tax_codes_or_fetch,
)
-from saleor.plugins import AvataxPlugin
+from saleor.plugins.avatax.plugin import AvataxPlugin
+from saleor.plugins.manager import get_plugins_manager
+from saleor.plugins.models import PluginConfiguration
@pytest.fixture
@@ -67,9 +67,7 @@ def test_calculate_checkout_line_total(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
checkout_with_item.shipping_address = address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -119,9 +117,7 @@ def test_calculate_checkout_total(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
checkout_with_item.shipping_address = address
checkout_with_item.save()
site_settings.company_address = address_usa
@@ -160,9 +156,7 @@ def test_calculate_checkout_shipping(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
site_settings.company_address = address_usa
site_settings.save()
@@ -209,9 +203,7 @@ def test_calculate_checkout_subtotal(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
site_settings.company_address = address_usa
site_settings.include_taxes_in_prices = taxes_in_prices
site_settings.save()
@@ -234,9 +226,7 @@ def test_calculate_order_shipping(
order_line, shipping_zone, site_settings, address_usa, plugin_configuration
):
plugin_configuration()
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
order = order_line.order
method = shipping_zone.shipping_methods.get()
order.shipping_address = order.billing_address.get_copy()
@@ -257,9 +247,7 @@ def test_calculate_order_line_unit(
order_line, shipping_zone, site_settings, address_usa, plugin_configuration,
):
plugin_configuration()
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
order_line.unit_price = TaxedMoney(
net=Money("10.00", "USD"), gross=Money("10.00", "USD")
)
@@ -300,9 +288,7 @@ def test_preprocess_order_creation(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
site_settings.company_address = address_usa
site_settings.save()
@@ -328,9 +314,7 @@ def test_preprocess_order_creation_wrong_data(
"saleor.plugins.avatax.plugin.get_cached_tax_codes_or_fetch",
lambda _: {"PC040156": "desc"},
)
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
checkout_with_item.shipping_address = address
checkout_with_item.shipping_method = shipping_zone.shipping_methods.get()
@@ -418,17 +402,12 @@ def test_show_taxes_on_storefront(plugin_configuration):
def test_order_created(order, monkeypatch, plugin_configuration):
plugin_configuration()
- manager = get_plugins_manager(
- plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"]
- )
+ manager = get_plugins_manager(plugins=["saleor.plugins.avatax.plugin.AvataxPlugin"])
mocked_task = Mock()
+ monkeypatch.setattr("saleor.plugins.avatax.plugin.get_order_tax_data", Mock())
monkeypatch.setattr(
- "saleor.plugins.avatax.plugin.get_order_tax_data", Mock()
- )
- monkeypatch.setattr(
- "saleor.plugins.avatax.plugin.api_post_request_task.delay",
- mocked_task,
+ "saleor.plugins.avatax.plugin.api_post_request_task.delay", mocked_task,
)
manager.order_created(order)
diff --git a/tests/extensions/plugins/test_plugins.py b/tests/plugins/plugins/test_plugins.py
similarity index 94%
rename from tests/extensions/plugins/test_plugins.py
rename to tests/plugins/plugins/test_plugins.py
index 3844d62197..77049d20c9 100644
--- a/tests/extensions/plugins/test_plugins.py
+++ b/tests/plugins/plugins/test_plugins.py
@@ -1,4 +1,5 @@
-from saleor.plugins import ConfigurationTypeField, AnonymizePlugin
+from saleor.plugins.anonymize.plugin import AnonymizePlugin
+from saleor.plugins.base_plugin import ConfigurationTypeField
from saleor.plugins.manager import get_plugins_manager
from tests.plugins.sample_plugins import PluginSample
from tests.plugins.utils import get_config_value
@@ -84,7 +85,7 @@ def test_base_plugin__append_config_structure_to_config(settings):
def test_change_user_address_in_anonymize_plugin_reset_phone(address, settings):
- settings.PLUGINS = ["saleor.plugins.plugins.anonymize.plugin.AnonymizePlugin"]
+ settings.PLUGINS = ["saleor.plugins.anonymize.plugin.AnonymizePlugin"]
manager = get_plugins_manager()
anonymize_plugin = manager.get_plugin(AnonymizePlugin.PLUGIN_NAME)
diff --git a/tests/extensions/plugins/test_vatlayer.py b/tests/plugins/plugins/test_vatlayer.py
similarity index 98%
rename from tests/extensions/plugins/test_vatlayer.py
rename to tests/plugins/plugins/test_vatlayer.py
index 0013507d56..b89a81f170 100644
--- a/tests/extensions/plugins/test_vatlayer.py
+++ b/tests/plugins/plugins/test_vatlayer.py
@@ -12,14 +12,14 @@ from saleor.checkout.utils import add_variant_to_checkout
from saleor.core.taxes import quantize_price, zero_taxed_money
from saleor.plugins.manager import get_plugins_manager
from saleor.plugins.models import PluginConfiguration
-from saleor.plugins.plugins.vatlayer import (
+from saleor.plugins.vatlayer import (
DEFAULT_TAX_RATE_NAME,
apply_tax_to_price,
get_tax_rate_by_name,
get_taxed_shipping_price,
get_taxes_for_country,
)
-from saleor.plugins import VatlayerPlugin
+from saleor.plugins.vatlayer.plugin import VatlayerPlugin
def get_url_path(url):
@@ -183,7 +183,7 @@ def test_apply_tax_to_price_no_taxes_raise_typeerror_for_invalid_type():
def test_vatlayer_plugin_caches_taxes(vatlayer, monkeypatch, product, address):
mocked_taxes = Mock(wraps=get_taxes_for_country)
monkeypatch.setattr(
- "saleor.plugins.plugins.vatlayer.plugin.get_taxes_for_country", mocked_taxes
+ "saleor.plugins.vatlayer.plugin.get_taxes_for_country", mocked_taxes
)
manager = get_plugins_manager()
@@ -386,8 +386,7 @@ def test_get_tax_rate_type_choices(vatlayer, settings, monkeypatch):
"admission to entertainment events",
]
monkeypatch.setattr(
- "saleor.plugins.vatlayer.plugin.get_tax_rate_types",
- lambda: expected_choices,
+ "saleor.plugins.vatlayer.plugin.get_tax_rate_types", lambda: expected_choices,
)
settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"]
manager = get_plugins_manager()
diff --git a/tests/extensions/plugins/test_webhook.py b/tests/plugins/plugins/test_webhook.py
similarity index 97%
rename from tests/extensions/plugins/test_webhook.py
rename to tests/plugins/plugins/test_webhook.py
index 60840ac2f4..65cf9b1f5d 100644
--- a/tests/extensions/plugins/test_webhook.py
+++ b/tests/plugins/plugins/test_webhook.py
@@ -18,9 +18,7 @@ from saleor.webhook.payloads import (
@pytest.mark.vcr
- "saleor.plugins.webhook.tasks.requests.post", wraps=requests.post
-)
[email protected]("saleor.plugins.webhook.tasks.requests.post", wraps=requests.post)
def test_trigger_webhooks_for_event(
mock_request,
webhook,
@@ -110,9 +108,7 @@ def test_trigger_webhooks_for_event_calls_expected_events(
@pytest.mark.vcr
- "saleor.plugins.webhook.tasks.requests.post", wraps=requests.post
-)
[email protected]("saleor.plugins.webhook.tasks.requests.post", wraps=requests.post)
def test_trigger_webhooks_for_event_with_secret_key(
mock_request, webhook, order_with_lines, permission_manage_orders
):
diff --git a/tests/extensions/sample_plugins.py b/tests/plugins/sample_plugins.py
similarity index 98%
rename from tests/extensions/sample_plugins.py
rename to tests/plugins/sample_plugins.py
index 8d3d91f8fe..c91472eb53 100644
--- a/tests/extensions/sample_plugins.py
+++ b/tests/plugins/sample_plugins.py
@@ -5,7 +5,7 @@ from django_countries.fields import Country
from prices import Money, TaxedMoney
from saleor.core.taxes import TaxType
-from saleor.plugins import ConfigurationTypeField, BasePlugin
+from saleor.plugins.base_plugin import BasePlugin, ConfigurationTypeField
from saleor.plugins.models import PluginConfiguration
from saleor.product.models import Product, ProductType
diff --git a/tests/extensions/test_checks.py b/tests/plugins/test_checks.py
similarity index 100%
rename from tests/extensions/test_checks.py
rename to tests/plugins/test_checks.py
diff --git a/tests/extensions/test_manager.py b/tests/plugins/test_manager.py
similarity index 94%
rename from tests/extensions/test_manager.py
rename to tests/plugins/test_manager.py
index 01acc8b154..88126022e4 100644
--- a/tests/extensions/test_manager.py
+++ b/tests/plugins/test_manager.py
@@ -61,9 +61,9 @@ def test_manager_calculates_checkout_shipping(
):
currency = checkout_with_item.currency
expected_shipping_price = Money(shipping_amount, currency)
- taxed_shipping_price = PluginsManager(
- plugins=plugins
- ).calculate_checkout_shipping(checkout_with_item, [discount_info])
+ taxed_shipping_price = PluginsManager(plugins=plugins).calculate_checkout_shipping(
+ checkout_with_item, [discount_info]
+ )
assert (
TaxedMoney(expected_shipping_price, expected_shipping_price)
== taxed_shipping_price
@@ -105,14 +105,12 @@ def test_manager_calculates_checkout_line_total(
@pytest.mark.parametrize(
"plugins, amount",
- [(["tests.extenspluginsions.sample_plugins.PluginSample"], "1.0"), ([], "12.30")],
+ [(["tests.plugins.sample_plugins.PluginSample"], "1.0"), ([], "12.30")],
)
def test_manager_calculates_order_line(order_line, plugins, amount):
currency = order_line.unit_price.currency
expected_price = Money(amount, currency)
- unit_price = PluginsManager(plugins=plugins).calculate_order_line_unit(
- order_line
- )
+ unit_price = PluginsManager(plugins=plugins).calculate_order_line_unit(order_line)
assert expected_price == unit_price.gross
@@ -127,9 +125,7 @@ def test_manager_calculates_order_line(order_line, plugins, amount):
],
)
def test_manager_uses_get_tax_rate_choices(plugins, tax_rate_list):
- assert (
- tax_rate_list == {PluginsManager}(plugins=plugins).get_tax_rate_type_choices()
- )
+ assert tax_rate_list == PluginsManager(plugins=plugins).get_tax_rate_type_choices()
@pytest.mark.parametrize(
@@ -225,9 +221,7 @@ def test_plugin_updates_configuration_shape(
plugin_configuration.configuration + [new_config],
)
- manager = PluginsManager(
- plugins=["tests.plugins.sample_plugins.PluginSample"]
- )
+ manager = PluginsManager(plugins=["tests.plugins.sample_plugins.PluginSample"])
plugin = manager.get_plugin("PluginSample")
assert len(plugin.configuration) == 5
@@ -243,9 +237,7 @@ def test_plugin_add_new_configuration(
)
config_structure = {"Foo": new_config_structure}
monkeypatch.setattr(PluginInactive, "CONFIG_STRUCTURE", config_structure)
- manager = PluginsManager(
- plugins=["tests.plugins.sample_plugins.PluginInactive"]
- )
+ manager = PluginsManager(plugins=["tests.plugins.sample_plugins.PluginInactive"])
plugin = manager.get_plugin("PluginInactive")
assert len(plugin.configuration) == 1
assert plugin.configuration[0] == {**new_config, **new_config_structure}
diff --git a/tests/extensions/utils.py b/tests/plugins/utils.py
similarity index 100%
rename from tests/extensions/utils.py
rename to tests/plugins/utils.py