repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
saleor
saleor/plugins/tests/gateways/dummy.py
.py
"""Fake payment gateway driving the legacy, plugin-based `Payment` flow in tests. It is not part of the shipped plugin set (`settings.BUILTIN_PLUGINS`) and has to be enabled explicitly through `settings.PLUGINS`. The gateway succeeds by default. Two hooks make it fail on demand: - monkeypatching `dummy_success` to r...
236
7,327
saleor
saleor/plugins/tests/fixtures/gateway.py
.py
import pytest @pytest.fixture(autouse=True) def setup_dummy_gateway(settings): settings.PLUGINS = ["saleor.plugins.tests.gateways.dummy.DummyGatewayPlugin"] return settings @pytest.fixture def sample_gateway(settings): settings.PLUGINS += [ "saleor.plugins.tests.sample_plugins.ActiveDummyPayment...
16
355
saleor
saleor/plugins/tests/fixtures/plugin_manager.py
.py
import pytest from ...manager import PluginsManager from ..sample_plugins import ALL_PLUGINS @pytest.fixture def plugins_manager(): return PluginsManager(plugins=[]) @pytest.fixture def all_plugins_manager(): plugins_as_module_paths = [p.__module__ + "." + p.__name__ for p in ALL_PLUGINS] return Plugin...
16
362
saleor
saleor/plugins/tests/fixtures/plugin_configuration.py
.py
import copy import pytest from ...base_plugin import ConfigurationTypeField from ...models import PluginConfiguration from ..sample_plugins import ( ChannelPluginSample, PluginInactive, PluginSample, ) @pytest.fixture def plugin_configuration(db): configuration, _ = PluginConfiguration.objects.get_o...
92
2,629
saleor
saleor/plugins/admin_email/constants.py
.py
import os from django.conf import settings DEFAULT_EMAIL_TEMPLATES_PATH = os.path.join( settings.PROJECT_ROOT, "saleor/plugins/admin_email/default_email_templates" ) STAFF_ORDER_CONFIRMATION_TEMPLATE_FIELD = "staff_order_confirmation_template" SET_STAFF_PASSWORD_TEMPLATE_FIELD = "set_staff_password_template" CSV...
45
1,825
saleor
saleor/plugins/admin_email/notify_events.py
.py
from collections.abc import Callable from typing import TYPE_CHECKING from ..email_common import get_email_subject, get_email_template_or_default from . import constants from .tasks import ( send_email_with_link_to_download_file_task, send_export_failed_email_task, send_set_staff_password_email_task, s...
142
4,738
saleor
saleor/plugins/admin_email/tasks.py
.py
from ...celeryconf import app from ...core.db.connection import allow_writer from ...csv.events import export_failed_info_sent_event, export_file_sent_event from ...graphql.core.utils import from_global_id_or_none from ..email_common import EmailConfig, send_email @app.task(compression="zlib") def send_set_staff_pass...
86
2,502
saleor
saleor/plugins/admin_email/plugin.py
.py
import logging from collections.abc import Callable from copy import deepcopy from dataclasses import asdict from django.conf import settings from promise.promise import Promise from ...core.notify import AdminNotifyEvent, NotifyEventType from ...graphql.plugins.dataloaders import EmailTemplatesByPluginConfigurationL...
320
12,218
saleor
saleor/plugins/admin_email/tests/test_tasks.py
.py
from unittest import mock from ....account.notifications import get_default_user_payload from ....csv import ExportEvents from ....csv.models import ExportEvent from ....csv.notifications import get_default_export_payload from ....order.notifications import get_default_order_payload from ...email_common import EmailCo...
357
11,085
saleor
saleor/plugins/admin_email/tests/test_notify_events.py
.py
from unittest import mock from ....account.notifications import get_default_user_payload from ....core.notify import NotifyHandler from ....order.notifications import get_default_order_payload from ..notify_events import ( send_csv_export_failed, send_csv_export_success, send_set_staff_password_email, ...
221
7,223
saleor
saleor/plugins/admin_email/tests/test_plugin.py
.py
from dataclasses import asdict from smtplib import SMTPNotSupportedError from unittest.mock import MagicMock, Mock, patch import pytest from django.core.exceptions import ValidationError from django.core.mail.backends.smtp import EmailBackend from ....core.notify import NotifyEventType from ....graphql.tests.utils im...
447
14,457
saleor
saleor/plugins/admin_email/tests/conftest.py
.py
from unittest.mock import patch import dj_email_url import pytest from ....plugins.models import EmailTemplate, PluginConfiguration from ...email_common import DEFAULT_EMAIL_VALUE from ...manager import get_plugins_manager from ..constants import ( CSV_EXPORT_FAILED_DEFAULT_SUBJECT, CSV_EXPORT_FAILED_SUBJECT_...
170
6,659
saleor
saleor/plugins/webhook/plugin.py
.py
import json import logging from collections import defaultdict from collections.abc import Callable, Iterable from decimal import Decimal from functools import partial from typing import TYPE_CHECKING, Any, Optional, Union, cast import graphene from django.conf import settings from django.utils.functional import LazyO...
3,557
125,753
saleor
saleor/plugins/webhook/conftest.py
.py
import pytest from ..manager import get_plugins_manager @pytest.fixture def webhook_plugin(settings): def factory(): settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"] manager = get_plugins_manager(allow_replica=False) manager.get_all_plugins() return manager.globa...
15
353
saleor
saleor/plugins/webhook/tests/utils.py
.py
def generate_request_headers(event_type, domain, signature): return { "Content-Type": "application/json", # X- headers will be deprecated in Saleor 4.0, proper headers are without X- "X-Saleor-Event": event_type, "X-Saleor-Domain": domain, "X-Saleor-Signature": signature, ...
13
487
saleor
saleor/plugins/webhook/tests/test_payment_webhook.py
.py
import datetime import json from typing import NamedTuple from unittest import mock import pytest from django.conf import settings from django.contrib.sites.models import Site from django.utils import timezone from requests import RequestException, TooManyRedirects from requests_hardened import HTTPSession from ....a...
589
20,862
saleor
saleor/plugins/webhook/tests/test_stored_payment_method_request_delete.py
.py
import json from unittest import mock import graphene import pytest from ....core.models import EventDelivery from ....payment.interface import ( ListStoredPaymentMethodsRequestData, StoredPaymentMethodRequestDeleteData, StoredPaymentMethodRequestDeleteResponseData, StoredPaymentMethodRequestDeleteRes...
470
15,384
saleor
saleor/plugins/webhook/tests/test_payment_method_process_tokenization.py
.py
import json from unittest import mock import graphene import pytest from ....core.models import EventDelivery from ....payment.interface import ( ListStoredPaymentMethodsRequestData, PaymentMethodProcessTokenizationRequestData, PaymentMethodTokenizationResponseData, PaymentMethodTokenizationResult, ) ...
546
17,633
saleor
saleor/plugins/webhook/tests/test_payment_method_initialize_tokenization.py
.py
import json from unittest import mock import graphene import pytest from ....core.models import EventDelivery from ....payment import TokenizedPaymentFlow from ....payment.interface import ( ListStoredPaymentMethodsRequestData, PaymentMethodInitializeTokenizationRequestData, PaymentMethodTokenizationRespo...
536
17,757
saleor
saleor/plugins/webhook/tests/test_app_lifecycle_webhooks.py
.py
"""End-to-end tests for app lifecycle webhook self-receive. Confirms an app without MANAGE_APPS permission receives its own APP_INSTALLED, APP_UPDATED, APP_DELETED, APP_STATUS_CHANGED events, and that the delivery-time gate keeps lifecycle deliveries when the receiving app is inactive (soft-deleted or deactivated). ""...
277
9,112
saleor
saleor/plugins/webhook/tests/test_transaction_initialize_session_webhook.py
.py
import json import uuid from decimal import Decimal from unittest import mock import graphene from freezegun import freeze_time from ....channel import TransactionFlowStrategy from ....core import EventDeliveryStatus from ....core.models import EventDelivery, EventPayload from ....payment.interface import ( Payme...
843
24,113
saleor
saleor/plugins/webhook/tests/test_tax_webhook.py
.py
from unittest.mock import sentinel import pytest from ....core.taxes import TaxType @pytest.fixture def tax_type(): return TaxType( code="code_2", description="description_2", ) def test_get_tax_code_from_object_meta_no_app( webhook_plugin, product, ): # given plugin = webh...
67
1,339
saleor
saleor/plugins/webhook/tests/test_transaction_process_session_webhook.py
.py
import json from decimal import Decimal from unittest import mock import graphene from freezegun import freeze_time from ....channel import TransactionFlowStrategy from ....core import EventDeliveryStatus from ....core.models import EventDelivery, EventPayload from ....payment.interface import ( PaymentGatewayDat...
734
20,792
saleor
saleor/plugins/webhook/tests/test_list_stored_payment_methods_webhook.py
.py
import json from unittest import mock import graphene from ....core.models import EventDelivery from ....payment.interface import ListStoredPaymentMethodsRequestData from ....settings import WEBHOOK_SYNC_TIMEOUT from ....webhook import const from ....webhook.event_types import WebhookEventSyncType from ....webhook.te...
360
11,701
saleor
saleor/plugins/webhook/tests/test_payment_gateway_initialize_tokenization.py
.py
import json from unittest import mock import graphene import pytest from ....core.models import EventDelivery from ....payment.interface import ( PaymentGatewayInitializeTokenizationRequestData, PaymentGatewayInitializeTokenizationResponseData, PaymentGatewayInitializeTokenizationResult, ) from ....settin...
254
8,131
saleor
saleor/plugins/webhook/tests/test_payment_gateway_initialize_session_webhook.py
.py
import json from decimal import Decimal from unittest import mock import graphene from freezegun import freeze_time from ....core import EventDeliveryStatus from ....core.models import EventDelivery, EventPayload from ....payment.interface import PaymentGatewayData from ....webhook.event_types import WebhookEventSync...
433
12,871
saleor
saleor/plugins/webhook/tests/test_webhook.py
.py
import datetime import json from decimal import Decimal from functools import partial from unittest import mock from unittest.mock import ANY, MagicMock from urllib.parse import urlencode import boto3 import graphene import pytest from celery.exceptions import MaxRetriesExceededError from celery.exceptions import Retr...
2,452
79,549
saleor
saleor/plugins/webhook/tests/conftest.py
.py
import pytest from ....plugins.manager import get_plugins_manager from ....plugins.webhook.plugin import WebhookPlugin @pytest.fixture def webhook_plugin(settings): def factory() -> WebhookPlugin: settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"] manager = get_plugins_manager(all...
16
433
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_metadata_updated.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
274
8,554
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_cancelled.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
230
7,004
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_product_variant_discounted_price_updated.py
.py
import json from decimal import Decimal from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......product.interface import VariantDiscountedPriceChange from ......
213
6,744
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_fulfilled.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
231
7,005
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_expired.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
232
6,970
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_fully_paid.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
231
7,019
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_fully_paid.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
248
7,442
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_metadata_updated.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
233
7,133
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_draft_order_deleted.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
195
5,661
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_fully_authorized.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
248
7,550
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_draft_order_created.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
236
7,072
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_confirmed.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
231
7,005
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_created.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
244
7,349
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_refunded.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
230
6,986
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_paid.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
232
6,916
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_created.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
229
6,967
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_updated.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
232
6,970
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_bulk_created.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
238
7,380
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_order_fully_refunded.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
232
7,092
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_draft_order_updated.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
234
7,076
saleor
saleor/plugins/webhook/tests/subscription_webhooks/filterable_webhooks/test_checkout_updated.py
.py
import json from unittest.mock import patch import graphene from django.test import override_settings from ......core.models import EventDelivery from ......graphql.webhook.subscription_query import SubscriptionQuery from ......webhook.event_types import WebhookEventAsyncType from .....manager import get_plugins_mana...
243
7,319
saleor
saleor/plugins/user_email/constants.py
.py
import os from django.conf import settings PLUGIN_ID = "mirumee.notifications.user_email" DEFAULT_EMAIL_TEMPLATES_PATH = os.path.join( settings.PROJECT_ROOT, "saleor/plugins/user_email/default_email_templates" ) ACCOUNT_CONFIRMATION_TEMPLATE_FIELD = "account_confirmation" ACCOUNT_SET_CUSTOMER_PASSWORD_TEMPLATE...
99
4,966
saleor
saleor/plugins/user_email/notify_events.py
.py
from collections.abc import Callable from typing import TYPE_CHECKING from ..email_common import get_email_subject, get_email_template_or_default from . import constants from .tasks import ( send_account_confirmation_email_task, send_account_delete_confirmation_email_task, send_fulfillment_confirmation_ema...
386
13,245
saleor
saleor/plugins/user_email/tasks.py
.py
from ...account import events as account_events from ...celeryconf import app from ...core.db.connection import allow_writer from ...giftcard import events as gift_card_events from ...graphql.core.utils import from_global_id_or_none from ...invoice import events as invoice_events from ...order import events as order_ev...
302
9,716
saleor
saleor/plugins/user_email/plugin.py
.py
import logging from collections.abc import Callable from dataclasses import asdict from typing import TYPE_CHECKING from django.conf import settings from promise.promise import Promise from ...core.notify import NotifyEventType, UserNotifyEvent from ...graphql.plugins.dataloaders import EmailTemplatesByPluginConfigur...
488
19,466
saleor
saleor/plugins/user_email/tests/test_tasks.py
.py
from unittest import mock from ....account.notifications import get_default_user_payload from ....giftcard import GiftCardEvents from ....giftcard.models import GiftCardEvent from ....graphql.core.utils import to_global_id_or_none from ....invoice import InvoiceEvents from ....invoice.models import Invoice, InvoiceEve...
1,311
42,921
saleor
saleor/plugins/user_email/tests/test_notify_events.py
.py
from unittest import mock from ....account.notifications import get_default_user_payload from ....core.notify import NotifyHandler from ....order.notifications import ( get_default_fulfillment_payload, get_default_order_payload, ) from ..notify_events import ( send_account_change_email_confirm, send_ac...
669
22,744
saleor
saleor/plugins/user_email/tests/test_plugin.py
.py
from dataclasses import asdict from smtplib import SMTPNotSupportedError from unittest.mock import MagicMock, Mock, patch import pytest from django.core.exceptions import ValidationError from django.core.mail.backends.smtp import EmailBackend from django.test import override_settings from ....core.notify import Notif...
427
13,108
saleor
saleor/plugins/user_email/tests/conftest.py
.py
from unittest.mock import patch import pytest from ....plugins.models import EmailTemplate, PluginConfiguration from ...email_common import DEFAULT_EMAIL_VALUE from ...manager import get_plugins_manager from ..constants import ( ACCOUNT_CHANGE_EMAIL_CONFIRM_DEFAULT_SUBJECT, ACCOUNT_CHANGE_EMAIL_CONFIRM_SUBJEC...
258
11,387
saleor
saleor/giftcard/gateway.py
.py
from decimal import Decimal from typing import Annotated from uuid import uuid4 import pydantic from django.db import transaction from django.db.models import Exists, F, OuterRef, Q from django.utils import timezone from ..account.models import User from ..app.models import App from ..checkout.models import Checkout ...
449
16,705
saleor
saleor/giftcard/notifications.py
.py
from typing import TYPE_CHECKING from ..account.notifications import get_default_user_payload from ..core.notification.utils import get_site_context from ..core.notify import NotifyEventType, NotifyHandler from ..core.prices import quantize_price from ..graphql.core.utils import to_global_id_or_none if TYPE_CHECKING:...
56
1,673
saleor
saleor/giftcard/utils.py
.py
import datetime import logging from collections import defaultdict from collections.abc import Iterable from typing import TYPE_CHECKING, Optional from uuid import UUID from dateutil.relativedelta import relativedelta from django.core.exceptions import ValidationError from django.db import transaction from django.db.m...
403
14,461
saleor
saleor/giftcard/error_codes.py
.py
from enum import Enum class GiftCardErrorCode(Enum): ALREADY_EXISTS = "already_exists" GRAPHQL_ERROR = "graphql_error" INVALID = "invalid" NOT_FOUND = "not_found" REQUIRED = "required" UNIQUE = "unique" EXPIRED_GIFT_CARD = "expired_gift_card" DUPLICATED_INPUT_ITEM = "duplicated_input_i...
14
361
saleor
saleor/giftcard/models.py
.py
import os from django.conf import settings from django.contrib.postgres.indexes import BTreeIndex, GinIndex from django.contrib.postgres.search import SearchVectorField from django.core.validators import MinLengthValidator from django.db import models from django.db.models import JSONField, Q from django.utils import ...
175
5,755
saleor
saleor/giftcard/__init__.py
.py
from dataclasses import dataclass from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..order.models import FulfillmentLine, OrderLine from ..product.models import ProductVariant class GiftCardEvents: """The different gift card event types.""" ISSUED = "issued" BOUGHT = "bought" ...
55
2,051
saleor
saleor/giftcard/search.py
.py
from django.conf import settings from django.db.models import Q, QuerySet, Value, prefetch_related_objects from ..account.models import User from ..core.db.connection import allow_writer from ..core.postgres import FlatConcatSearchVector, NoValidationSearchVector from .models import GiftCard GIFTCARD_FIELDS_TO_PREFET...
70
2,755
saleor
saleor/giftcard/tasks.py
.py
from celery.utils.log import get_task_logger from django.conf import settings from django.utils import timezone from ..celeryconf import app from ..core.db.connection import allow_writer from .events import gift_cards_deactivated_event from .models import GiftCard from .search import update_gift_cards_search_vector t...
40
1,301
saleor
saleor/giftcard/const.py
.py
GIFT_CARD_PAYMENT_GATEWAY_ID = "saleor.io.gift-card-payment-gateway" GIFT_CARD_PAYMENT_GATEWAY_NAME = "Gift Card Payment Gateway" SALEOR_GIFT_CARD_PAYMENT_METHOD_NAME = "Saleor Gift Card" SALEOR_GIFT_CARD_BRAND = "Saleor"
5
222
saleor
saleor/giftcard/events.py
.py
from collections.abc import Iterable from decimal import Decimal from typing import TYPE_CHECKING from ..account.models import User from ..app.models import App from . import GiftCardEvents from .models import GiftCard, GiftCardEvent if TYPE_CHECKING: from ..order.models import Order def gift_card_issued_event(...
346
9,013
saleor
saleor/giftcard/tests/test_notifications.py
.py
from unittest import mock from ...account.notifications import get_default_user_payload from ...core.notify import NotifyEventType from ...core.tests.utils import get_site_context_payload from ...graphql.core.utils import to_global_id_or_none from ...plugins.manager import get_plugins_manager from ..notifications impo...
65
2,167
saleor
saleor/giftcard/tests/test_tasks.py
.py
import datetime import pytest from django.utils import timezone from .. import GiftCardEvents from ..models import GiftCard from ..tasks import deactivate_expired_cards_task, update_gift_cards_search_vector_task def test_update_gift_cards_search_vector_task(gift_card): # given gift_card.search_index_dirty =...
90
2,500
saleor
saleor/giftcard/tests/test_gateway.py
.py
from decimal import Decimal import pytest from ...giftcard import GiftCardEvents from ...giftcard.const import GIFT_CARD_PAYMENT_GATEWAY_ID from ...giftcard.gateway import ( charge_gift_card_transactions, refund_gift_card_transaction, ) from ...giftcard.models import GiftCardEvent from ...payment import Trans...
133
4,281
saleor
saleor/giftcard/tests/test_lock_objects.py
.py
from ..lock_objects import gift_card_qs_select_for_update from ..models import GiftCard def test_gift_card_qs_select_for_update_returns_giftcard_queryset(gift_card): # when qs = gift_card_qs_select_for_update() # then assert qs.model is GiftCard assert qs.query.select_for_update is True
12
311
saleor
saleor/giftcard/tests/test_models.py
.py
from decimal import Decimal import pytest from django.db import IntegrityError, transaction from django.db.models import ProtectedError from ..models import GiftCard def test_gift_card_can_be_assigned_to_customer(gift_card, customer_user): # when gift_card.assigned_to = customer_user gift_card.assigned_...
44
1,617
saleor
saleor/giftcard/tests/test_events.py
.py
from decimal import Decimal from .. import GiftCardEvents from ..events import ( gift_card_assigned_event, gift_card_balance_adjusted_event, gift_card_unassigned_event, ) def test_gift_card_balance_adjusted_event(gift_card, staff_user): # given old_current = Decimal("50.00") old_initial = Dec...
59
1,974
saleor
saleor/giftcard/tests/test_utils.py
.py
import datetime import json from unittest.mock import patch import graphene import pytest from dateutil.relativedelta import relativedelta from django.core.exceptions import ValidationError from django.db.models import QuerySet from django.utils import timezone from freezegun import freeze_time from ...checkout.error...
1,165
36,620
saleor
saleor/giftcard/tests/fixtures/giftcard.py
.py
import datetime import secrets import pytest from ....core.prices import Money from ....graphql.giftcard.tests.benchmark import GIFT_CARD_COUNT_IN_BENCHMARKS from ... import GiftCardEvents from ...models import GiftCard, GiftCardEvent, GiftCardTag @pytest.fixture def gift_card(customer_user): gift_card = GiftCa...
148
4,186
saleor
saleor/giftcard/tests/fixtures/giftcard_tag.py
.py
import pytest from ...models import GiftCardTag @pytest.fixture def gift_card_tag_list(db): tags = [GiftCardTag(name=f"test-tag-{i}") for i in range(5)] return GiftCardTag.objects.bulk_create(tags)
10
209
saleor
saleor/giftcard/tests/fixtures/giftcard_event.py
.py
import datetime import pytest from django.utils import timezone from ... import GiftCardEvents from ...models import GiftCardEvent @pytest.fixture def gift_card_event(gift_card, order, app, staff_user): parameters = { "message": "test message", "email": "testemail@email.com", "tags": ["t...
36
955
saleor
saleor/app/types.py
.py
class AppType: LOCAL = "local" THIRDPARTY = "thirdparty" CHOICES = [(LOCAL, "local"), (THIRDPARTY, "thirdparty")] # Deprecated. Remove this enum in 3.24, when this field is dropped from AppExtension model class DeprecatedAppExtensionHttpMethod: """HTTP methods available for app extensions. Repre...
26
758
saleor
saleor/app/utils.py
.py
from ..webhook.event_types import WebhookEventSyncType from ..webhook.utils import get_webhooks_for_event def get_active_tax_apps(identifiers: list[str] | None = None): checkout_webhooks = get_webhooks_for_event( event_type=WebhookEventSyncType.CHECKOUT_CALCULATE_TAXES, apps_identifier=identifiers...
19
652
saleor
saleor/app/lock_objects.py
.py
from django.db.models import QuerySet from .models import App, AppProblem def app_qs_select_for_update() -> QuerySet[App]: return App.objects.order_by("pk").select_for_update(of=["self"]) def app_problem_qs_select_for_update() -> QuerySet[AppProblem]: return AppProblem.objects.order_by("pk").select_for_upd...
12
337
saleor
saleor/app/error_codes.py
.py
from enum import Enum class AppErrorCode(Enum): FORBIDDEN = "forbidden" GRAPHQL_ERROR = "graphql_error" INVALID = "invalid" INVALID_STATUS = "invalid_status" INVALID_PERMISSION = "invalid_permission" INVALID_URL_FORMAT = "invalid_url_format" INVALID_MANIFEST_FORMAT = "invalid_manifest_form...
37
1,167
saleor
saleor/app/models.py
.py
from collections.abc import Iterable from typing import cast from uuid import uuid4 from django.contrib.auth.hashers import make_password from django.db import models from django.utils.text import Truncator from oauthlib.common import generate_token from ..core.models import Job, ModelWithMetadata from ..permission.e...
252
9,366
saleor
saleor/app/apps.py
.py
from django.apps import AppConfig as DjangoAppConfig from django.db.models.signals import post_delete class AppConfig(DjangoAppConfig): name = "saleor.app" def ready(self): from .models import App, AppInstallation from .signals import delete_brand_images # preventing duplicate signal...
23
643
saleor
saleor/app/manifest_schema.py
.py
import mimetypes from django.core.exceptions import ValidationError as DjangoValidationError from pydantic import BaseModel, ConfigDict, field_validator from pydantic.alias_generators import to_camel from pydantic_core import PydanticCustomError from ..thumbnail import ICON_MIME_TYPES from ..webhook.response_schemas....
143
4,335
saleor
saleor/app/headers.py
.py
class AppHeaders: DOMAIN = "Saleor-Domain" EVENT_TYPE = "Saleor-Event" SIGNATURE = "Saleor-Signature" API_URL = "Saleor-Api-Url" SCHEMA_VERSION = "Saleor-Schema-Version" class DeprecatedAppHeaders: DOMAIN = "X-Saleor-Domain" EVENT_TYPE = "X-Saleor-Event" SIGNATURE = "X-Saleor-Signature...
13
322
saleor
saleor/app/signals.py
.py
from ..core.tasks import delete_from_storage_task def delete_brand_images(sender, instance, **kwargs): if img := instance.brand_logo_default: delete_from_storage_task.delay(img.name)
7
197
saleor
saleor/app/installation_utils.py
.py
import logging import time from io import BytesIO import requests from celery.exceptions import MaxRetriesExceededError from celery.utils.log import get_task_logger from django.conf import settings from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.files import File from django.cor...
340
12,477
saleor
saleor/app/tasks.py
.py
import logging from django.conf import settings from django.core.exceptions import ValidationError from django.db.models import Exists, OuterRef, Q from django.utils import timezone from requests import HTTPError, RequestException from .. import celeryconf from ..core import JobStatus from ..core.db.connection import...
124
4,539
saleor
saleor/app/manifest_validations.py
.py
import logging from collections import defaultdict from collections.abc import Iterable from django.core.exceptions import ValidationError from django.db.models import Value from django.db.models.functions import Concat from pydantic import ValidationError as PydanticValidationError from semantic_version import NpmSpe...
379
13,504
saleor
saleor/app/validators.py
.py
import re from django.core.validators import URLValidator from .error_codes import AppErrorCode class AppURLValidator(URLValidator): validator = URLValidator host_re = "(" + validator.hostname_re + validator.domain_re + "|localhost)" regex = re.compile( r"^(?:[a-z0-9.+-]*)://" # scheme is valid...
26
758
saleor
saleor/app/actions.py
.py
import logging from django.utils import timezone from ..core.telemetry import get_task_context from ..core.utils.events import call_event from ..plugins.manager import PluginsManager from ..webhook.event_types import WebhookEventAsyncType from ..webhook.transport.asynchronous.transport import ( create_deliveries_...
76
2,518
saleor
saleor/app/management/commands/utils.py
.py
from django.core.management import CommandError from ....permission.enums import ( AppPermission, get_permissions, get_permissions_enum_list, ) def clean_permissions(required_permissions: list[str]): all_permissions = {perm[0]: perm[1] for perm in get_permissions_enum_list()} for perm in required...
29
1,155
saleor
saleor/app/management/commands/app_delete_all.py
.py
from typing import Any from django.core.management import BaseCommand from django.core.management.base import CommandParser from ....plugins.manager import get_plugins_manager from ...actions import delete_app from ...models import App class Command(BaseCommand): help = ( "Soft-delete every installed ap...
43
1,426
saleor
saleor/app/management/commands/install_app.py
.py
import json from typing import Any from django.core.exceptions import ValidationError from django.core.management import BaseCommand, CommandError from django.core.management.base import CommandParser from ....app.models import App from ....app.validators import AppURLValidator from ....core import JobStatus from ......
83
2,730
saleor
saleor/app/management/commands/create_app.py
.py
import json from typing import Any import graphene from django.core.management import BaseCommand, CommandError from django.core.management.base import CommandParser from django.urls import reverse from requests.exceptions import RequestException from .... import schema_version from ....app.headers import AppHeaders,...
104
3,648
saleor
saleor/app/tests/test_installation_utils.py
.py
import json from unittest.mock import ANY, Mock, patch import graphene import pytest import requests from celery.exceptions import Retry from django.core.exceptions import ValidationError from django.core.files import File from django.core.files.base import ContentFile from django.db import DatabaseError from freezegu...
1,060
35,151
saleor
saleor/app/tests/test_models.py
.py
import pytest from django.db import IntegrityError from django.db.transaction import atomic from ...app.models import App from ...webhook.event_types import WebhookEventSyncType from ..models import AppExtension, AppInstallation def test_qs_for_event_type(payment_app): qs = App.objects.for_event_type(WebhookEven...
135
4,196
saleor
saleor/app/tests/test_manifest_validations.py
.py
import pytest from django.core.exceptions import ValidationError from pydantic import ValidationError as PydanticValidationError from ...permission.enums import AppPermission, ProductPermissions from ..error_codes import AppErrorCode from ..manifest_schema import ( EXTENSION_IDENTIFIER_MAX_LENGTH, ICON_MIME_TY...
773
23,095
saleor
saleor/app/tests/test_app_actions.py
.py
import json from unittest.mock import Mock, patch import graphene from ...core.models import EventDelivery, EventPayload from ...webhook.event_types import WebhookEventAsyncType from ...webhook.models import Webhook from ..actions import delete_app from ..models import App def test_delete_app_soft_deletes_and_calls...
116
3,531
saleor
saleor/app/tests/test_validators.py
.py
import pytest from django.core.exceptions import ValidationError from ... import __version__ from ...app.validators import ( AppURLValidator, ) from ..error_codes import AppErrorCode from ..manifest_validations import ( _clean_extension_url, _clean_required_saleor_version, _parse_version, ) def test_...
82
2,401