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/shipping/tests/test_postal_codes.py
.py
from unittest.mock import Mock, patch import pytest from .. import PostalCodeRuleInclusionType from ..postal_codes import ( check_postal_code_in_range, is_shipping_method_applicable_for_postal_code, ) @pytest.mark.parametrize( ("code", "start", "end", "in_range"), [ ("BH3 2BC", "BH2 1AA", "B...
125
4,408
saleor
saleor/shipping/tests/test_shipping.py
.py
import pytest from django_countries import countries from measurement.measures import Weight from prices import Money from ..models import ( ShippingMethod, ShippingMethodChannelListing, ShippingMethodType, ShippingZone, ) from ..utils import default_shipping_zone_exists, get_countries_without_shipping...
384
13,457
saleor
saleor/shipping/tests/webhooks/test_shared.py
.py
from unittest import mock import graphene from promise import Promise from ....webhook.event_types import WebhookEventSyncType from ....webhook.models import Webhook from ....webhook.response_schemas.shipping import logger as schema_logger from ....webhook.response_schemas.utils.annotations import logger as annotatio...
125
3,838
saleor
saleor/shipping/tests/fixtures/shipping_method.py
.py
import pytest from ....core.prices import Money from ...models import ShippingMethod, ShippingMethodChannelListing, ShippingMethodType @pytest.fixture def shipping_method(shipping_zone, channel_USD, default_tax_class): method = ShippingMethod.objects.create( name="DHL", type=ShippingMethodType.PR...
101
2,957
saleor
saleor/shipping/tests/fixtures/shipping_zone.py
.py
import pytest from django_countries import countries from ....core.prices import Money from ....warehouse.models import Warehouse from ...models import ShippingMethodChannelListing, ShippingMethodType, ShippingZone @pytest.fixture def shipping_zone(db, channel_USD, default_tax_class): # pylint: disable=W0613 sh...
188
6,531
saleor
saleor/shipping/tests/fixtures/shipping_method_translation.py
.py
import pytest from ...models import ShippingMethodTranslation @pytest.fixture def shipping_method_translation_fr(shipping_method): return ShippingMethodTranslation.objects.create( language_code="fr", shipping_method=shipping_method, name="French shipping method name", )
13
306
saleor
saleor/shipping/tests/fixtures/shipping_method_data.py
.py
import pytest from ...models import ShippingMethodChannelListing from ...utils import convert_to_shipping_method_data @pytest.fixture def shipping_method_data(shipping_method, channel_USD): listing = ShippingMethodChannelListing.objects.filter( channel=channel_USD, shipping_method=shipping_method ).g...
13
394
saleor
saleor/payment/model_helpers.py
.py
from collections.abc import Iterable from operator import attrgetter from typing import TYPE_CHECKING from ..core.taxes import zero_money, zero_taxed_money from .models import Payment if TYPE_CHECKING: from ..order.models import OrderLine def get_last_payment(payments: Iterable[Payment]): return max(payment...
27
904
saleor
saleor/payment/gateway.py
.py
import logging from collections.abc import Callable from decimal import Decimal from typing import TYPE_CHECKING, Optional, cast from ..account.models import User from ..app.models import App from ..checkout.fetch import ( CheckoutInfo, CheckoutLineInfo, ) from ..core.prices import quantize_price from ..core.t...
633
19,497
saleor
saleor/payment/utils.py
.py
import json import logging from decimal import Decimal from typing import Any, Optional, cast, get_args, overload from uuid import UUID import graphene from babel.numbers import get_currency_precision from django.conf import settings from django.core.serializers.json import DjangoJSONEncoder from django.db import Inte...
2,081
76,084
saleor
saleor/payment/lock_objects.py
.py
from typing import TYPE_CHECKING, Optional from uuid import UUID from django.db.models import QuerySet from ..checkout.lock_objects import checkout_qs_select_for_update from ..order.lock_objects import order_qs_select_for_update from .models import TransactionItem if TYPE_CHECKING: from ..checkout.models import ...
37
1,239
saleor
saleor/payment/error_codes.py
.py
from enum import Enum class PaymentErrorCode(Enum): BILLING_ADDRESS_NOT_SET = "billing_address_not_set" GRAPHQL_ERROR = "graphql_error" INVALID = "invalid" NOT_FOUND = "not_found" REQUIRED = "required" UNIQUE = "unique" PARTIAL_PAYMENT_NOT_ALLOWED = "partial_payment_not_allowed" SHIPPI...
135
4,187
saleor
saleor/payment/models.py
.py
from decimal import Decimal from operator import attrgetter from uuid import uuid4 from django.conf import settings from django.contrib.postgres.fields import ArrayField from django.contrib.postgres.indexes import BTreeIndex, GinIndex from django.core.serializers.json import DjangoJSONEncoder from django.core.validato...
510
18,312
saleor
saleor/payment/__init__.py
.py
from enum import Enum class PaymentError(Exception): def __init__(self, message, code=None): super().__init__(message, code) self.message = message self.code = code def __str__(self): return self.message class GatewayError(IOError): pass class TransactionItemIdempotenc...
306
9,624
saleor
saleor/payment/transaction_item_calculations.py
.py
from collections import defaultdict from collections.abc import Iterable from dataclasses import dataclass, field from decimal import Decimal from typing import cast from . import TransactionEventType from .models import TransactionEvent, TransactionItem @dataclass class BaseEvent: request: TransactionEvent | No...
400
14,802
saleor
saleor/payment/dataloaders.py
.py
from collections import defaultdict from ..graphql.core.dataloaders import DataLoader from .models import Payment class PaymentsByOrderIdLoader(DataLoader): context_key = "payments_by_order" def batch_load(self, keys): payments = ( Payment.objects.using(self.database_connection_name) ...
20
619
saleor
saleor/payment/interface.py
.py
import datetime from collections.abc import Callable from dataclasses import InitVar, dataclass, field from decimal import Decimal from enum import Enum from functools import cached_property from typing import TYPE_CHECKING, Any, Optional, Union from ..order import FulfillmentLineData from ..order.fetch import OrderLi...
460
12,812
saleor
saleor/payment/tasks.py
.py
import datetime import logging import uuid import graphene from django.conf import settings from django.db import transaction from django.db.models import DateTimeField, Exists, ExpressionWrapper, OuterRef, Q from ..celeryconf import app from ..channel.models import Channel from ..checkout import CheckoutAuthorizeSta...
220
8,910
saleor
saleor/payment/gateways/utils.py
.py
import warnings from typing import TYPE_CHECKING if TYPE_CHECKING: from ..interface import GatewayConfig def get_supported_currencies(config: "GatewayConfig", gateway_name: str) -> list[str]: """Return supported currencies for given gateway configuration. If supported currencies are not specified, the d...
26
798
saleor
saleor/payment/gateways/stripe/webhooks.py
.py
import logging from typing import cast import stripe from django.core.exceptions import ValidationError from django.db.models import Prefetch from django.http import HttpResponse from stripe.error import SignatureVerificationError from stripe.stripe_object import StripeObject from ....checkout.calculations import cal...
559
18,290
saleor
saleor/payment/gateways/stripe/stripe_api.py
.py
import logging from contextlib import contextmanager from decimal import Decimal from urllib.parse import urljoin import stripe from django.urls import reverse from stripe.error import AuthenticationError, InvalidRequestError, StripeError from stripe.stripe_object import StripeObject from ....core.tracing import otel...
320
10,082
saleor
saleor/payment/gateways/stripe/consts.py
.py
PLUGIN_ID = "saleor.payments.stripe" PLUGIN_NAME = "Stripe (deprecated)" PLUGIN_DESCRIPTION = """ Stripe Plugin has been deprecated and will be removed in the future. Use the Stripe App instead. https://docs.saleor.io/developer/app-store/apps/stripe/overview """ WEBHOOK_PATH = "webhooks/" WEBHOOK_SUCCESS_EVENT = "pay...
47
1,230
saleor
saleor/payment/gateways/stripe/plugin.py
.py
import logging from typing import TYPE_CHECKING from django.core.exceptions import ValidationError from django.http import HttpResponse, HttpResponseNotFound from django.http.request import split_domain_port from ....core.utils import get_domain from ....graphql.core import SaleorContext from ....graphql.core.enums i...
608
23,510
saleor
saleor/payment/gateways/stripe/tests/test_plugin_deprecated.py
.py
from unittest.mock import Mock, patch from .... import TransactionKind from ....utils import create_payment_information, price_to_minor_unit from ..consts import AUTOMATIC_CAPTURE_METHOD, SUCCESS_STATUS @patch("saleor.payment.gateways.stripe.stripe_api.stripe.Customer.create") @patch("saleor.payment.gateways.stripe....
81
2,801
saleor
saleor/payment/gateways/stripe/tests/test_webhooks.py
.py
import json import logging from decimal import Decimal from unittest.mock import Mock, patch import pytest from django.core.exceptions import ValidationError from django.utils import timezone from stripe.stripe_object import StripeObject from .....checkout.calculations import calculate_checkout_total_with_gift_cards ...
1,813
57,053
saleor
saleor/payment/gateways/stripe/tests/test_stripe_api.py
.py
from decimal import Decimal from unittest.mock import patch from stripe.error import AuthenticationError, StripeError from stripe.stripe_object import StripeObject from saleor.payment.interface import PaymentMethodInfo from saleor.payment.utils import price_to_minor_unit from ..consts import ( AUTOMATIC_CAPTURE_...
521
14,482
saleor
saleor/payment/gateways/stripe/tests/test_plugin.py
.py
import warnings from unittest.mock import Mock, patch import pytest from django.core.exceptions import ValidationError from stripe.error import AuthenticationError, StripeError from stripe.stripe_object import StripeObject from .....plugins.models import PluginConfiguration from .... import TransactionKind from ....i...
1,637
54,903
saleor
saleor/payment/gateways/stripe/tests/conftest.py
.py
import pytest from stripe.stripe_object import StripeObject from .....checkout import calculations from .....checkout.fetch import fetch_checkout_info, fetch_checkout_lines from .....plugins.manager import get_plugins_manager from .....plugins.models import PluginConfiguration from .... import TransactionKind from ......
167
5,846
saleor
saleor/payment/tests/test_tasks.py
.py
import datetime from decimal import Decimal from unittest import mock from freezegun import freeze_time from ...checkout import CheckoutAuthorizeStatus, CheckoutChargeStatus from ...checkout.actions import transaction_amounts_for_checkout_updated from .. import TransactionAction, TransactionEventType from ..tasks imp...
494
16,931
saleor
saleor/payment/tests/test_transaction_item_calculations.py
.py
import datetime from decimal import Decimal from django.utils import timezone from freezegun import freeze_time from .. import TransactionEventType from ..models import TransactionItem from ..transaction_item_calculations import recalculate_transaction_amounts def _assert_amounts( transaction: TransactionItem, ...
1,667
46,614
saleor
saleor/payment/tests/test_gateway.py
.py
from decimal import Decimal from unittest.mock import Mock, patch import pytest from ...order import OrderEvents from ...plugins.manager import get_plugins_manager from ...webhook.event_types import WebhookEventSyncType from ...webhook.models import Webhook from .. import ( ChargeStatus, CustomPaymentChoices,...
1,529
48,927
saleor
saleor/payment/tests/test_gateways_utils.py
.py
import warnings import pytest from ..gateways.utils import get_supported_currencies from ..interface import GatewayConfig @pytest.fixture def gateway_config(): return GatewayConfig( gateway_name="Dummy", auto_capture=True, supported_currencies="", connection_params={"secret-key":...
54
1,393
saleor
saleor/payment/tests/test_payment.py
.py
import uuid from decimal import Decimal from unittest.mock import Mock, patch import pytest from ...checkout.calculations import calculate_checkout_total from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines from ...core.prices import quantize_price from ...plugins.manager import PluginsManager, get...
781
24,763
saleor
saleor/payment/tests/test_utils/test_parse_transaction_action_data_for_session_webhook.py
.py
import datetime from decimal import Decimal import pytest from freezegun import freeze_time from ... import TransactionEventType from ...interface import TransactionRequestEventResponse, TransactionSessionResponse from ...utils import ( parse_transaction_action_data_for_session_webhook, ) @pytest.mark.parametri...
262
8,146
saleor
saleor/payment/tests/test_utils/test_create_transaction_event_for_transaction_session.py
.py
import datetime import logging from decimal import Decimal from unittest.mock import patch import pytest from freezegun import freeze_time from ....order import OrderAuthorizeStatus from ... import TransactionEventType from ...models import TransactionEvent from ...utils import ( create_transaction_event_for_tran...
1,146
36,813
saleor
saleor/payment/tests/test_utils/test_parse_transaction_action_data_for_action_webhook.py
.py
import datetime from decimal import Decimal import pytest from freezegun import freeze_time from ... import TransactionEventType from ...interface import ( TransactionRequestEventResponse, TransactionRequestResponse, ) from ...utils import ( parse_transaction_action_data_for_action_webhook, ) def test_p...
271
8,870
saleor
saleor/payment/tests/test_utils/test_utils.py
.py
import datetime import logging from decimal import Decimal from unittest.mock import patch import graphene import pytest from freezegun import freeze_time from ....checkout import CheckoutAuthorizeStatus, calculations from ....checkout.fetch import fetch_checkout_info, fetch_checkout_lines from ....order import Order...
2,714
85,428
saleor
saleor/payment/tests/fixtures/gateway_config.py
.py
import pytest from ....payment.interface import GatewayConfig @pytest.fixture def dummy_gateway_config(): return GatewayConfig( gateway_name="Dummy", auto_capture=True, supported_currencies="USD", connection_params={"secret-key": "nobodylikesspanishinqusition"}, )
14
308
saleor
saleor/payment/tests/fixtures/payment_data.py
.py
from decimal import Decimal import graphene import pytest from ....payment.interface import PaymentData @pytest.fixture def dummy_payment_data(payment_dummy): return PaymentData( gateway=payment_dummy.gateway, amount=Decimal(10), currency="USD", graphql_payment_id=graphene.Node.t...
23
550
saleor
saleor/payment/tests/fixtures/transaction_event.py
.py
from collections.abc import Callable from decimal import Decimal import pytest from ....payment.models import TransactionEvent, TransactionItem @pytest.fixture def transaction_events_generator() -> Callable[ [list[str], list[str], list[Decimal], TransactionItem], list[TransactionEvent] ]: def factory( ...
34
954
saleor
saleor/payment/tests/fixtures/payment.py
.py
import pytest from ....payment import ChargeStatus, TransactionKind from ....payment.models import Payment from ....webhook.transport.utils import to_payment_app_id @pytest.fixture def payment_dummy(db, order_with_lines): return Payment.objects.create( gateway="mirumee.payments.dummy", order=orde...
192
5,942
saleor
saleor/payment/tests/fixtures/transaction_item.py
.py
import uuid from decimal import Decimal import pytest from ...models import TransactionItem from ...transaction_item_calculations import recalculate_transaction_amounts from ...utils import create_manual_adjustment_events @pytest.fixture def transaction_item_generator(): def create_transaction( order_id...
114
3,322
saleor
saleor/payment/tests/fixtures/gateway_response.py
.py
from decimal import Decimal import pytest from ....payment import TransactionKind from ....payment.interface import GatewayResponse @pytest.fixture def action_required_gateway_response(): return GatewayResponse( is_success=True, action_required=True, action_required_data={ "p...
46
1,154
saleor
saleor/asgi/telemetry.py
.py
from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, Scope, ) from ..core.telemetry import saleor_attributes, set_global_attributes def get_hostname(scope: Scope) -> str: if scope["type"] == "http": for header, value in scope["headers"]: if hea...
29
836
saleor
saleor/asgi/gzip_compression.py
.py
# adapted from Starlette's GZipMiddleware # Starlette does not work with Django's case-sensitive headers import gzip import io import secrets from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, ASGISendEvent, HTTPResponseStartEvent, Scope, ) def _get_random_...
166
6,988
saleor
saleor/asgi/__init__.py
.py
"""ASGI config for Saleor project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ """ import gc import os from django.conf import settings from ..core.telemetry import initialize_tele...
48
1,492
saleor
saleor/asgi/health_check.py
.py
from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, HTTPResponseBodyEvent, HTTPResponseStartEvent, Scope, ) def health_check(application: ASGI3Application, health_url: str) -> ASGI3Application: async def health_check_wrapper( scope: Scope, receive:...
31
929
saleor
saleor/asgi/cors_handler.py
.py
from fnmatch import fnmatchcase from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, ASGISendEvent, HTTPResponseBodyEvent, HTTPResponseStartEvent, Scope, ) from django.conf import settings def cors_handler(application: ASGI3Application) -> ASGI3Application...
112
4,260
saleor
saleor/asgi/asgi_handler.py
.py
"""Code copied from Django Software Foundation (https://djangoproject.com/) which is licensed under the BSD 3-Clause. Original code: https://github.com/django/django/blob/001c2f546b4053acb04f16d6b704f7b4fbca1c45/django/core/handlers/asgi.py Modifications: we added a fix for a memory leak (https://code.djangoproject.c...
127
5,563
saleor
saleor/asgi/usage_telemetry.py
.py
import asyncio import hashlib import json import logging import random import sys from asgiref.sync import sync_to_async from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, Scope, ) from django.apps import apps from django.conf import settings from django.db import con...
235
8,181
saleor
saleor/asgi/tests/asgi_test_utils.py
.py
from asgiref.typing import Scope, WebSocketScope from django.core.handlers.asgi import ASGIHandler class DummyASGIApplication(ASGIHandler): """A dummy ASGI application that always return a dummy string. Used to indicate it was called successfully. """ RESPONSE_STRING = "Dummy ASGI Application: calle...
37
1,154
saleor
saleor/asgi/tests/test_cors.py
.py
import pytest from asgiref.typing import ( ASGI3Application, ASGIReceiveEvent, HTTPResponseBodyEvent, HTTPResponseStartEvent, HTTPScope, ) from ..cors_handler import cors_handler ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin" ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Cr...
147
5,070
saleor
saleor/asgi/tests/test_healthcheck.py
.py
from unittest import mock from saleor.asgi import health_check from saleor.asgi.tests.asgi_test_utils import ( DummyASGIApplication, create_asgi_scope_websocket_proto, ) async def test_non_http_requests_forwarded_to_next_wrapper(): """Ensure the middleware forwards the request when the protocol isn't HTT...
47
1,661
saleor
saleor/asgi/tests/test_telemetry.py
.py
from unittest.mock import AsyncMock, MagicMock, patch import pytest from asgiref.typing import ASGIReceiveCallable, ASGISendCallable from ...asgi.telemetry import get_hostname, telemetry_middleware from ...core.telemetry.saleor_attributes import SALEOR_ENVIRONMENT_DOMAIN @pytest.mark.parametrize( ("scope", "exp...
91
2,366
saleor
saleor/asgi/tests/test_usage_telemetry.py
.py
from datetime import timedelta from django.utils import timezone from ..usage_telemetry import get_usage_telemetry def test_get_usage_telemetry(site_settings): # given site_settings.usage_telemetry_reported_at = None site_settings.save(update_fields=["usage_telemetry_reported_at"]) expected_instanc...
64
1,548
saleor
saleor/asgi/tests/test_gzip.py
.py
import gzip from unittest import mock from asgiref.typing import ( ASGI3Application, ASGIReceiveEvent, HTTPResponseBodyEvent, HTTPResponseStartEvent, HTTPScope, ) from ..gzip_compression import gzip_compression def build_scope(origin: str, encodings: bytes) -> HTTPScope: return { "ty...
208
6,867
saleor
saleor/asgi/tests/conftest.py
.py
import pytest from asgiref.typing import ( ASGI3Application, ASGIReceiveCallable, ASGISendCallable, HTTPResponseBodyEvent, HTTPResponseStartEvent, Scope, ) @pytest.fixture def asgi_app() -> ASGI3Application: async def fake_app( scope: Scope, receive: ASGIReceiveCallable, send: ASGI...
55
1,417
saleor
saleor/order/notifications.py
.py
from collections import defaultdict from collections.abc import Iterable from dataclasses import dataclass from decimal import Decimal from functools import partial from typing import TYPE_CHECKING, Optional from urllib.parse import urlencode from django.conf import settings from django.forms import model_to_dict fro...
584
20,106
saleor
saleor/order/delivery_context.py
.py
import logging from collections.abc import Iterable from typing import TYPE_CHECKING, Union from django.conf import settings from promise import Promise from ..shipping.interface import ExcludedShippingMethod, ShippingMethodData from ..shipping.models import ShippingMethod, ShippingMethodChannelListing from ..shippin...
136
4,456
saleor
saleor/order/utils.py
.py
import logging from collections.abc import Iterable from datetime import datetime, timedelta from decimal import Decimal from typing import TYPE_CHECKING, Optional, cast import graphene from django.conf import settings from django.core.exceptions import ValidationError from django.db import transaction from django.db....
1,326
48,965
saleor
saleor/order/lock_objects.py
.py
from django.db.models import QuerySet from .models import Order, OrderLine def order_lines_qs_select_for_update() -> QuerySet[OrderLine]: return OrderLine.objects.order_by("pk").select_for_update(of=["self"]) def order_qs_select_for_update() -> QuerySet[Order]: return Order.objects.order_by("pk").select_fo...
12
344
saleor
saleor/order/error_codes.py
.py
from enum import Enum class OrderErrorCode(Enum): BILLING_ADDRESS_NOT_SET = "billing_address_not_set" CANNOT_CANCEL_FULFILLMENT = "cannot_cancel_fulfillment" CANNOT_CANCEL_ORDER = "cannot_cancel_order" CANNOT_DELETE = "cannot_delete" CANNOT_DISCOUNT = "cannot_discount" CANNOT_REFUND = "cannot_...
110
3,901
saleor
saleor/order/models.py
.py
from decimal import Decimal from operator import attrgetter from re import match from typing import TYPE_CHECKING, cast from uuid import uuid4 from django.conf import settings from django.contrib.postgres.indexes import BTreeIndex, GinIndex from django.contrib.postgres.search import SearchVectorField from django.core....
997
34,037
saleor
saleor/order/fetch.py
.py
from collections.abc import Iterable from dataclasses import dataclass from typing import Optional, cast from uuid import UUID from django.db.models import prefetch_related_objects from ..channel.models import Channel from ..core.db.connection import allow_writer from ..core.prices import quantize_price from ..core.p...
286
9,513
saleor
saleor/order/__init__.py
.py
from dataclasses import dataclass from typing import TYPE_CHECKING if TYPE_CHECKING: from ..page.models import Page from .models import FulfillmentLine class OrderStatus: DRAFT = "draft" # fully editable, not finalized order created by staff users UNCONFIRMED = ( "unconfirmed" # order creat...
351
13,584
saleor
saleor/order/calculations.py
.py
import logging from collections.abc import Iterable from decimal import Decimal from typing import TYPE_CHECKING, Union from uuid import UUID from django.conf import settings from django.db import transaction from django.utils import timezone from prices import Money, TaxedMoney from promise import Promise from ..cor...
1,164
40,002
saleor
saleor/order/search.py
.py
from typing import TYPE_CHECKING import graphene from django.conf import settings from django.db.models import Value, prefetch_related_objects from ..account.search import generate_address_search_vector_value, generate_email_vector from ..core.postgres import FlatConcatSearchVector, NoValidationSearchVector from . im...
263
8,678
saleor
saleor/order/interface.py
.py
from dataclasses import dataclass from prices import TaxedMoney @dataclass class OrderTaxedPricesData: """Store an order prices data with applied taxes. 'price_with_discounts' includes voucher discount and sale discount if any valid exists. 'undiscounted_price' is a price without any sale and vouche...
17
404
saleor
saleor/order/tasks.py
.py
import datetime import logging from collections import Counter from django.conf import settings from django.contrib.sites.models import Site from django.db.models import Exists, F, Func, OuterRef, Subquery, Value from django.db.models.functions import Greatest from django.utils import timezone from ..account.lock_obj...
244
8,318
saleor
saleor/order/base_calculations.py
.py
from collections.abc import Iterable from typing import TYPE_CHECKING, cast from django.conf import settings from prices import Money, TaxedMoney from ..core.prices import quantize_price from ..core.taxes import zero_money from ..discount import DiscountType, DiscountValueType from ..discount.models import OrderDisco...
366
13,737
saleor
saleor/order/events.py
.py
from decimal import Decimal from typing import TYPE_CHECKING, Optional from ..account import events as account_events from ..account.models import User from ..app.models import App from ..discount.models import OrderDiscount from ..order.models import Fulfillment, FulfillmentLine, Order, OrderLine from ..payment.model...
935
23,539
saleor
saleor/order/actions.py
.py
import logging from collections import defaultdict from copy import deepcopy from decimal import Decimal from typing import TYPE_CHECKING, Optional, TypedDict from uuid import UUID import graphene from django.contrib.sites.models import Site from django.db import transaction from django.db.models import F from ..acco...
2,111
74,528
saleor
saleor/order/webhooks/exclude_shipping.py
.py
import json import logging from typing import TYPE_CHECKING, Union from promise import Promise from ...core.db.connection import allow_writer from ...core.prices import quantize_price from ...core.utils.json_serializer import CustomJsonEncoder from ...shipping.interface import ExcludedShippingMethod, ShippingMethodDa...
130
4,120
saleor
saleor/order/webhooks/order_calculate_taxes.py
.py
import json import logging from collections.abc import Iterable from typing import TYPE_CHECKING, Union import graphene from django.db.models import QuerySet from promise import Promise from ...app.models import App from ...core.db.connection import allow_writer from ...core.prices import quantize_price, quantize_pri...
158
5,235
saleor
saleor/order/tests/test_fulfillments_actions.py
.py
from unittest.mock import patch import pytest from django.core.exceptions import ValidationError from ...core.exceptions import InsufficientStock from ...order import OrderEvents from ...plugins.manager import get_plugins_manager from ...warehouse.models import Allocation, Stock from ..actions import create_fulfillme...
802
25,456
saleor
saleor/order/tests/test_notifications.py
.py
from decimal import Decimal from functools import partial from unittest import mock import graphene from django.core.files import File from measurement.measures import Weight from prices import Money, fixed_discount from ...attribute.tests.model_helpers import ( get_product_attribute_values, get_product_attri...
801
28,780
saleor
saleor/order/tests/test_tasks.py
.py
import datetime from unittest import mock from unittest.mock import ANY, patch import pytest from django.test import override_settings from django.utils import timezone from freezegun import freeze_time from ...account.models import User from ...core.models import EventDelivery from ...discount.models import VoucherC...
821
24,218
saleor
saleor/order/tests/test_refresh_all_order_base_prices_and_discounts.py
.py
from datetime import timedelta from decimal import Decimal import graphene import pytest from django.utils import timezone from freezegun import freeze_time from ...core.prices import quantize_price from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType, RewardValueType, VoucherT...
613
26,501
saleor
saleor/order/tests/test_order_search.py
.py
from decimal import Decimal from ...discount import DiscountValueType from ..models import OrderLine from ..search import prepare_order_search_vector_value, update_order_search_vector def test_update_order_search_vector_auto_save(order): # given order.search_vector = "" order.save(update_fields=["search_...
115
3,134
saleor
saleor/order/tests/test_order_actions.py
.py
from decimal import Decimal from unittest.mock import ANY, call, patch import pytest from django.test import override_settings from ...channel import MarkAsPaidStrategy from ...core.models import EventDelivery from ...core.utils.events import call_event from ...giftcard import GiftCardEvents from ...giftcard.const im...
3,198
108,765
saleor
saleor/order/tests/test_order_actions_refund_products.py
.py
from decimal import Decimal from unittest.mock import ANY, patch from ...payment import ChargeStatus from ...payment.interface import RefundData from ...plugins.manager import get_plugins_manager from ...warehouse.models import Allocation from .. import FulfillmentLineData, FulfillmentStatus from ..actions import crea...
282
10,935
saleor
saleor/order/tests/test_order_utils.py
.py
import datetime from decimal import Decimal import graphene import pytest from django.utils import timezone from prices import Money, TaxedMoney from ...checkout.fetch import fetch_checkout_info, fetch_checkout_lines from ...checkout.models import Checkout from ...discount import DiscountType, DiscountValueType from ...
804
24,613
saleor
saleor/order/tests/test_fetch_order_prices_line_price_expiration.py
.py
from datetime import timedelta from decimal import Decimal import graphene import pytest from django.utils import timezone from ...core.prices import quantize_price from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType, RewardValueType, VoucherType from ...discount.models import...
1,755
74,630
saleor
saleor/order/tests/test_base_order_total.py
.py
from decimal import ROUND_HALF_UP, Decimal from prices import Money from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType from .. import base_calculations def test_base_order_total(order_with_lines): # given order = order_with_lines lines = order.lines.all() sh...
625
20,427
saleor
saleor/order/tests/test_fetch_order_prices.py
.py
from decimal import Decimal import graphene import pytest from ...core.prices import quantize_price from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType, VoucherType from ...discount.models import OrderDiscount, OrderLineDiscount, PromotionRule from ...discount.utils.voucher im...
2,042
78,666
saleor
saleor/order/tests/test_fetch.py
.py
from decimal import Decimal import pytest from ...product.models import ProductVariantChannelListing from ..fetch import EditableOrderLineInfo, fetch_draft_order_lines_info @pytest.mark.django_db @pytest.mark.count_queries(autouse=False) def test_fetch_draft_order_lines_info( draft_order_and_promotions, django_...
156
5,477
saleor
saleor/order/tests/test_order.py
.py
from decimal import Decimal from unittest.mock import patch import graphene import pytest from prices import Money, TaxedMoney from ...core.utils.translations import get_translation from ...core.weight import zero_weight from ...discount import DiscountType, RewardValueType from ...discount.interface import VariantPr...
1,392
44,185
saleor
saleor/order/tests/test_refresh_order_base_prices_and_discounts.py
.py
from datetime import timedelta from decimal import Decimal import graphene import pytest from django.utils import timezone from freezegun import freeze_time from ...core.prices import quantize_price from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType, RewardValueType, VoucherT...
750
32,469
saleor
saleor/order/tests/test_calculate_prices.py
.py
from decimal import Decimal import pytest from prices import Money, TaxedMoney from ...core.prices import quantize_price from ...core.taxes import zero_money from ...discount import DiscountType, DiscountValueType from ...order.base_calculations import ( apply_subtotal_discount_to_order_lines, calculate_price...
757
27,393
saleor
saleor/order/tests/test_base_order_line_total.py
.py
from prices import TaxedMoney from .. import base_calculations from ..interface import OrderTaxedPricesData def test_base_order_line_total(order_with_lines): # given line = order_with_lines.lines.all().first() # when order_total = base_calculations.base_order_line_total(line) # then base_li...
29
896
saleor
saleor/order/tests/test_order_actions_create_fulfillments_for_returned_products.py
.py
from decimal import Decimal from unittest.mock import ANY, patch from prices import Money, TaxedMoney from ...page.models import Page, PageType from ...payment.interface import RefundData from ...plugins.manager import get_plugins_manager from ...warehouse.models import Allocation, Stock from .. import FulfillmentLin...
862
34,069
saleor
saleor/order/tests/test_calculations.py
.py
import dataclasses from decimal import Decimal from typing import Literal from unittest.mock import Mock, patch, sentinel import pytest from django.test import override_settings from prices import Money, TaxedMoney from promise import Promise from ...core.prices import quantize_price from ...core.taxes import ( T...
1,998
69,725
saleor
saleor/order/tests/test_shipping_context.py
.py
from ...shipping.models import ShippingMethod, ShippingMethodType from ..delivery_context import ( get_all_shipping_methods_for_order, get_valid_shipping_methods_for_order, ) def test_get_valid_shipping_methods_for_order(order_line_with_one_allocation, address): # given order = order_line_with_one_all...
170
4,877
saleor
saleor/order/tests/test_fetch_order_prices_tax_app.py
.py
import dataclasses from decimal import Decimal from unittest.mock import patch import graphene import pytest from promise import Promise from ...core.prices import quantize_price from ...core.taxes import TaxData, TaxLineData from ...discount import DiscountType, DiscountValueType, VoucherType from ...discount.models...
1,750
67,356
saleor
saleor/order/tests/test_actions.py
.py
from unittest.mock import patch import pytest from ...graphql.core.utils import to_global_id_or_none from ...webhook.utils import get_webhooks_for_multiple_events from .. import OrderStatus from ..actions import ( WEBHOOK_EVENTS_FOR_ORDER_CREATED, _get_extra_for_order_line_logger, _get_extra_for_order_log...
181
5,334
saleor
saleor/order/tests/webhooks/test_exclude_shipping.py
.py
import json import uuid from decimal import Decimal from unittest import mock from unittest.mock import call import graphene import pytest from measurement.measures import Weight from prices import Money from promise import Promise from ....core.prices import quantize_price from ....shipping.interface import Shipping...
537
16,995
saleor
saleor/order/tests/webhooks/test_order_calculate_taxes.py
.py
import json from unittest.mock import ANY, patch import pytest from freezegun import freeze_time from ....core import EventDeliveryStatus from ....core.models import EventDelivery from ....core.taxes import TaxDataError from ....graphql.webhook.subscription_payload import ( generate_payload_promise_from_subscript...
249
7,977
saleor
saleor/order/tests/webhooks/test_exclude_shipping_cache.py
.py
import json import uuid from decimal import Decimal from unittest import mock import graphene import pytest from measurement.measures import Weight from prices import Money from ....core.prices import quantize_price from ....shipping.interface import ShippingMethodData from ....shipping.webhooks.shared import CACHE_E...
255
7,786
saleor
saleor/order/tests/webhooks/static_payloads/test_order_calculate_taxes.py
.py
import datetime import json from decimal import Decimal from unittest.mock import patch import graphene import pytest from freezegun import freeze_time from .....core.prices import quantize_price from .....discount import DiscountType, DiscountValueType, VoucherType from .....webhook.serializers import serialize_vari...
366
13,543
saleor
saleor/order/tests/webhooks/subscriptions/test_exclude_shipping.py
.py
import json import graphene import pytest from .....shipping.models import ShippingMethodChannelListing from .....webhook.event_types import WebhookEventSyncType from .....webhook.transport.synchronous.transport import ( create_delivery_for_subscription_sync_event, ) from ....delivery_context import get_all_shipp...
156
4,213