Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' into feature/convert_service_account_into_app
Maciej Korycinskib5a1fe82f285
diff --cc saleor/account/migrations/0041_auto_20200416_0100.pyindex 0af0a5e1ad,0000000000..23d6327a18mode 100644,000000..100644--- a/saleor/account/migrations/0041_auto_20200416_0100.py+++ b/saleor/account/migrations/0041_auto_20200416_0100.py@@@ -1,37 -1,0 +1,37 @@@+# Generated by Django 3.0.5 on 2020-04-16 06:00++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("core", "0001_migrate_metadata"),+ ("auth", "0011_update_proxy_permissions"),+ ("webhook", "0002_webhook_name"),- ("account", "0039_auto_20200221_0257"),++ ("account", "0040_auto_20200415_0443"),+ ]++ operations = [+ migrations.RenameModel(old_name="ServiceAccount", new_name="App",),+ migrations.RenameModel(old_name="ServiceAccountToken", new_name="AppToken",),+ migrations.AlterModelTable(name="app", table="app_app",),+ migrations.AlterModelTable(name="apptoken", table="app_apptoken",),+ migrations.RenameField(+ model_name="apptoken", old_name="service_account", new_name="app",+ ),+ migrations.AlterModelOptions(+ name="app", options={"permissions": (("manage_apps", "Manage apps"),)},+ ),+ migrations.AlterField(+ model_name="app",+ name="permissions",+ field=models.ManyToManyField(+ blank=True,+ help_text="Specific permissions for this app.",+ related_name="app_set",+ related_query_name="app",+ to="auth.Permission",+ ),+ ),+ ]diff --cc saleor/account/migrations/0042_auto_20200416_0107.pyindex ff6ed5024e,0000000000..5bfc286516mode 100644,000000..100644--- a/saleor/account/migrations/0042_auto_20200416_0107.py+++ b/saleor/account/migrations/0042_auto_20200416_0107.py@@@ -1,21 -1,0 +1,21 @@@+# Generated by Django 3.0.5 on 2020-04-16 06:07++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [- ("account", "0040_auto_20200416_0100"),++ ("account", "0041_auto_20200416_0100"),+ ("webhook", "0003_unmount_service_account"),+ ]++ state_operations = [+ migrations.RemoveField(model_name="apptoken", name="app",),+ migrations.DeleteModel(name="App",),+ migrations.DeleteModel(name="AppToken",),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(state_operations=state_operations)+ ]diff --cc saleor/app/migrations/0001_initial.pyindex dd24679411,0000000000..c8f9c56459mode 100644,000000..100644--- a/saleor/app/migrations/0001_initial.py+++ b/saleor/app/migrations/0001_initial.py@@@ -1,156 -1,0 +1,156 @@@+# Generated by Django 3.0.5 on 2020-04-15 06:21++import django.contrib.postgres.fields.jsonb+import django.db.models.deletion+import oauthlib.common+from django.db import migrations, models++import saleor.core.utils.json_serializer+++def update_contentypes(apps, schema_editor):+ """Update content types.++ We want to have the same content type id, when the model is moved.+ """+ ContentType = apps.get_model("contenttypes", "ContentType")+ db_alias = schema_editor.connection.alias+ # Move the ServiceAccount to app module+ qs = ContentType.objects.using(db_alias).filter(app_label="account", model="app")+ qs.update(app_label="app")++ # Move the ServiceAccountToken to app module+ qs = ContentType.objects.using(db_alias).filter(+ app_label="account", model="apptoken"+ )+ qs.update(app_label="app")+++def update_contentypes_reverse(apps, schema_editor):+ """Revert changes in content types."""+ ContentType = apps.get_model("contenttypes", "ContentType")+ db_alias = schema_editor.connection.alias++ qs = ContentType.objects.using(db_alias).filter(app_label="app", model="app")+ qs.update(app_label="account")++ qs = ContentType.objects.using(db_alias).filter(app_label="app", model="apptoken")+ qs.update(app_label="account")+++def convert_service_account_permissions_to_app_permissions(apps, schema_editor):+ Permission = apps.get_model("auth", "Permission")+ service_account_permission = Permission.objects.filter(+ codename="manage_service_accounts", content_type__app_label="app"+ ).first()+ if service_account_permission:+ service_account_permission.codename = "manage_apps"+ service_account_permission.name = "Manage apps"+ service_account_permission.save()+++class Migration(migrations.Migration):++ initial = True++ dependencies = [+ ("auth", "0011_update_proxy_permissions"),- ("account", "0041_auto_20200416_0107"),++ ("account", "0042_auto_20200416_0107"),+ ]++ state_operations = [+ migrations.CreateModel(+ name="App",+ fields=[+ (+ "id",+ models.AutoField(+ auto_created=True,+ primary_key=True,+ serialize=False,+ verbose_name="ID",+ ),+ ),+ ("name", models.CharField(max_length=60)),+ ("created", models.DateTimeField(auto_now_add=True)),+ ("is_active", models.BooleanField(default=True)),+ (+ "permissions",+ models.ManyToManyField(+ blank=True,+ help_text="Specific permissions for this app.",+ related_name="app_set",+ related_query_name="app",+ to="auth.Permission",+ ),+ ),+ (+ "metadata",+ django.contrib.postgres.fields.jsonb.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ (+ "private_metadata",+ django.contrib.postgres.fields.jsonb.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ ],+ options={+ "db_table": "app_app",+ "permissions": (("manage_apps", "Manage apps"),),+ },+ ),+ migrations.CreateModel(+ name="AppToken",+ fields=[+ (+ "id",+ models.AutoField(+ auto_created=True,+ primary_key=True,+ serialize=False,+ verbose_name="ID",+ ),+ ),+ ("name", models.CharField(blank=True, default="", max_length=128)),+ (+ "auth_token",+ models.CharField(+ default=oauthlib.common.generate_token,+ max_length=30,+ unique=True,+ ),+ ),+ (+ "app",+ models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="tokens",+ to="app.App",+ ),+ ),+ ],+ options={"db_table": "app_apptoken"},+ ),+ ]++ database_operations = [+ migrations.RunPython(update_contentypes, update_contentypes_reverse),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=state_operations, database_operations=database_operations+ ),+ migrations.AlterModelTable(name="app", table=None,),+ migrations.AlterModelTable(name="apptoken", table=None,),+ migrations.RunPython(convert_service_account_permissions_to_app_permissions),+ ]diff --cc saleor/core/permissions.pyindex 7d6851cbe5,960b492f27..786fdb96ac--- a/saleor/core/permissions.py+++ b/saleor/core/permissions.py@@@ -67,9 -62,8 +67,9 @@@ class WebhookPermissions(BasePermissionPERMISSIONS_ENUMS = [AccountPermissions,+ AppPermission,DiscountPermissions,- ExtensionsPermissions,+ PluginsPermissions,GiftcardPermissions,MenuPermissions,OrderPermissions,diff --cc saleor/graphql/account/schema.pyindex f817f05f18,62703f5ada..6f1fafab6c--- a/saleor/graphql/account/schema.py+++ b/saleor/graphql/account/schema.py@@@ -310,14 -304,14 +313,14 @@@ class AccountMutations(graphene.ObjectTservice_account_update_private_metadata = ServiceAccountUpdatePrivateMeta.Field(deprecation_reason=(- "Use the `updatePrivateMetadata` mutation. This field will be removed "- "after 2020-07-31."++ "Use the `updatePrivateMetadata` mutation with App instead."+ "This field will be removed after 2020-07-31."- "Use the `UpdatePrivateMetadata` mutation with App instead."))service_account_clear_private_metadata = ServiceAccountClearPrivateMeta.Field(deprecation_reason=(- "This field will be removed after 2020-07-31."- "Use the `deletePrivateMetadata` mutation. This field will be removed "- "after 2020-07-31."+ "Use the `DeletePrivateMetadata` mutation with App instead."++ "This field will be removed after 2020-07-31."))diff --cc saleor/graphql/api.pyindex 1592ccd332,330cf8cf5d..b4e2290d3d--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@@ -5,13 -4,13 +5,13 @@@ from .app.schema import AppMutations, Afrom .checkout.schema import CheckoutMutations, CheckoutQueriesfrom .core.schema import CoreMutations, CoreQueriesfrom .discount.schema import DiscountMutations, DiscountQueries- from .extensions.schema import ExtensionsMutations, ExtensionsQueries-from .plugins.schema import PluginsMutations, PluginsQueriesfrom .giftcard.schema import GiftCardMutations, GiftCardQueriesfrom .menu.schema import MenuMutations, MenuQueriesfrom .meta.schema import MetaMutationsfrom .order.schema import OrderMutations, OrderQueriesfrom .page.schema import PageMutations, PageQueriesfrom .payment.schema import PaymentMutations, PaymentQueries++from .plugins.schema import PluginsMutations, PluginsQueriesfrom .product.schema import ProductMutations, ProductQueriesfrom .shipping.schema import ShippingMutations, ShippingQueriesfrom .shop.schema import ShopMutations, ShopQueriesdiff --cc saleor/graphql/core/enums.pyindex cd69c71acc,5a6a555752..74f28a5e3d--- a/saleor/graphql/core/enums.py+++ b/saleor/graphql/core/enums.py@@@ -1,9 -1,8 +1,9 @@@import graphenefrom ...account import error_codes as account_error_codes+from ...app import error_codes as app_error_codesfrom ...checkout import error_codes as checkout_error_codes- from ...core import error_codes as core_error_codes+ from ...core import JobStatus, error_codes as core_error_codesfrom ...core.permissions import get_permissions_enum_listfrom ...core.weight import WeightUnitsfrom ...discount import error_codes as discount_error_codes@@@ -86,12 -83,9 +84,10 @@@ WeightUnitsEnum = graphene.EnumAccountErrorCode = graphene.Enum.from_enum(account_error_codes.AccountErrorCode)+AppErrorCode = graphene.Enum.from_enum(app_error_codes.AppErrorCode)CheckoutErrorCode = graphene.Enum.from_enum(checkout_error_codes.CheckoutErrorCode)DiscountErrorCode = graphene.Enum.from_enum(discount_error_codes.DiscountErrorCode)- ExtensionsErrorCode = graphene.Enum.from_enum(- extensions_error_codes.ExtensionsErrorCode- )+ PluginErrorCode = graphene.Enum.from_enum(plugin_error_codes.PluginErrorCode)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 --cc saleor/graphql/core/types/common.pyindex dca7877821,419dbdcf8d..bb5fee2662--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@@ -4,11 -4,10 +4,11 @@@ from ....product.templatetags.product_ifrom ...translations.enums import LanguageCodeEnumfrom ..enums import (AccountErrorCode,+ AppErrorCode,CheckoutErrorCode,DiscountErrorCode,- ExtensionsErrorCode,GiftCardErrorCode,+ JobStatusEnum,MenuErrorCode,MetadataErrorCode,OrderErrorCode,diff --cc saleor/graphql/schema.graphqlindex bdfd6294ee,0c3db39c3f..a4fe43fcb4--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@@ -184,110 -185,8 +185,110 @@@ type AddressValidationDatapostalCodePrefix: String}+type App implements Node & ObjectWithMetadata {+ id: ID!+ name: String+ created: DateTime+ isActive: Boolean+ permissions: [PermissionDisplay]+ tokens: [AppToken]+ privateMetadata: [MetadataItem]!+ metadata: [MetadataItem]!- privateMeta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `privetaMetadata` field instead. ")- meta: [MetaStore]! @deprecated(reason: "DEPRECATED: Will be removed in Saleor 2.11. use the `metadata` field instead. ")++ privateMeta: [MetaStore]! @deprecated(reason: "Use the `privetaMetadata` field. This field will be removed after 2020-07-31.")++ meta: [MetaStore]! @deprecated(reason: "Use the `metadata` field. This field will be removed after 2020-07-31.")+}++type AppCountableConnection {+ pageInfo: PageInfo!+ edges: [AppCountableEdge!]!+ totalCount: Int+}++type AppCountableEdge {+ node: App!+ cursor: String!+}++type AppCreate {- errors: [Error!]!++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ authToken: String+ appErrors: [AppError!]!+ app: App+}++type AppDelete {- errors: [Error!]!++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ appErrors: [AppError!]!+ app: App+}++type AppError {+ field: String+ message: String+ code: AppErrorCode!+}++enum AppErrorCode {+ GRAPHQL_ERROR+ INVALID+ NOT_FOUND+ REQUIRED+ UNIQUE+}++input AppFilterInput {+ search: String+ isActive: Boolean+}++input AppInput {+ name: String+ isActive: Boolean+ permissions: [PermissionEnum]+}++enum AppSortField {+ NAME+ CREATION_DATE+}++input AppSortingInput {+ direction: OrderDirection!+ field: AppSortField!+}++type AppToken implements Node {+ name: String+ authToken: String+ id: ID!+}++type AppTokenCreate {- errors: [Error!]!++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ authToken: String+ appErrors: [AppError!]!+ appToken: AppToken+}++type AppTokenDelete {- errors: [Error!]!++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ appErrors: [AppError!]!+ appToken: AppToken+}++input AppTokenInput {+ name: String+ app: ID!+}++type AppUpdate {- errors: [Error!]!++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")+ appErrors: [AppError!]!+ app: App+}+type AssignNavigation {- errors: [Error!]!+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")menu: MenumenuErrors: [MenuError!]!}@@@ -2472,15 -2362,10 +2464,15 @@@ type MutationcheckoutPaymentCreate(checkoutId: ID!, input: PaymentInput!): CheckoutPaymentCreatecheckoutShippingAddressUpdate(checkoutId: ID!, shippingAddress: AddressInput!): CheckoutShippingAddressUpdatecheckoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!): CheckoutShippingMethodUpdate- checkoutUpdateMetadata(id: ID!, input: MetaInput!): CheckoutUpdateMeta @deprecated(reason: "Will be removed in Saleor 2.11. Use the `UpdateMetadata` mutation instead.")- checkoutClearMetadata(id: ID!, input: MetaPath!): CheckoutClearMeta @deprecated(reason: "Will be removed in Saleor 2.11. Use the `DeleteMetadata` mutation instead.")- checkoutUpdatePrivateMetadata(id: ID!, input: MetaInput!): CheckoutUpdatePrivateMeta @deprecated(reason: "Will be removed in Saleor 2.11.Use the `UpdatePrivateMetadata` mutation instead.")- checkoutClearPrivateMetadata(id: ID!, input: MetaPath!): CheckoutClearPrivateMeta @deprecated(reason: "Will be removed in Saleor 2.11.Use the `DeletePrivateMetadata` mutation instead.")+ checkoutUpdateMetadata(id: ID!, input: MetaInput!): CheckoutUpdateMeta @deprecated(reason: "Use the `updateMetadata` mutation. This field will be removed after 2020-07-31.")+ checkoutClearMetadata(id: ID!, input: MetaPath!): CheckoutClearMeta @deprecated(reason: "Use the `deleteMetadata` mutation. This field will be removed after 2020-07-31.")+ checkoutUpdatePrivateMetadata(id: ID!, input: MetaInput!): CheckoutUpdatePrivateMeta @deprecated(reason: "Use the `updatePrivateMetadata` mutation. This field will be removed after 2020-07-31.")+ checkoutClearPrivateMetadata(id: ID!, input: MetaPath!): CheckoutClearPrivateMeta @deprecated(reason: "Use the `deletePrivateMetadata` mutation. This field will be removed after 2020-07-31.")+ appCreate(input: AppInput!): AppCreate+ appUpdate(id: ID!, input: AppInput!): AppUpdate+ appDelete(id: ID!): AppDelete+ appTokenCreate(input: AppTokenInput!): AppTokenCreate+ appTokenDelete(id: ID!): AppTokenDeleterequestPasswordReset(email: String!, redirectUrl: String!): RequestPasswordResetconfirmAccount(email: String!, token: String!): ConfirmAccountsetPassword(token: String!, email: String!, password: String!): SetPassword@@@ -2511,17 -2396,17 +2503,17 @@@userAvatarUpdate(image: Upload!): UserAvatarUpdateuserAvatarDelete: UserAvatarDeleteuserBulkSetActive(ids: [ID]!, isActive: Boolean!): UserBulkSetActive- userUpdateMetadata(id: ID!, input: MetaInput!): UserUpdateMeta @deprecated(reason: "Will be removed in Saleor 2.11. Use the `UpdateMetadata` mutation instead.")- userClearMetadata(id: ID!, input: MetaPath!): UserClearMeta @deprecated(reason: "Will be removed in Saleor 2.11. Use the `DeleteMetadata` mutation instead.")- userUpdatePrivateMetadata(id: ID!, input: MetaInput!): UserUpdatePrivateMeta @deprecated(reason: "Will be removed in Saleor 2.11.Use the `UpdatePrivateMetadata` mutation instead.")- userClearPrivateMetadata(id: ID!, input: MetaPath!): UserClearPrivateMeta @deprecated(reason: "Will be removed in Saleor 2.11.Use the `DeletePrivateMetadata` mutation instead.")+ userUpdateMetadata(id: ID!, input: MetaInput!): UserUpdateMeta @deprecated(reason: "Use the `updateMetadata` mutation. This field will be removed after 2020-07-31.")+ userClearMetadata(id: ID!, input: MetaPath!): UserClearMeta @deprecated(reason: "Use the `deleteMetadata` mutation. This field will be removed after 2020-07-31.")+ userUpdatePrivateMetadata(id: ID!, input: MetaInput!): UserUpdatePrivateMeta @deprecated(reason: "Use the `updatePrivateMetadata` mutation. This field will be removed after 2020-07-31.")+ userClearPrivateMetadata(id: ID!, input: MetaPath!): UserClearPrivateMeta @deprecated(reason: "Use the `deletePrivateMetadata` mutation. This field will be removed after 2020-07-31.")- serviceAccountCreate(input: ServiceAccountInput!): ServiceAccountCreate- serviceAccountUpdate(id: ID!, input: ServiceAccountInput!): ServiceAccountUpdate- serviceAccountDelete(id: ID!): ServiceAccountDelete- serviceAccountUpdatePrivateMetadata(id: ID!, input: MetaInput!): ServiceAccountUpdatePrivateMeta @deprecated(reason: "Use the `updatePrivateMetadata` mutation. This field will be removed after 2020-07-31.")- serviceAccountClearPrivateMetadata(id: ID!, input: MetaPath!): ServiceAccountClearPrivateMeta @deprecated(reason: "Use the `deletePrivateMetadata` mutation. This field will be removed after 2020-07-31.")- serviceAccountTokenCreate(input: ServiceAccountTokenInput!): ServiceAccountTokenCreate- serviceAccountTokenDelete(id: ID!): ServiceAccountTokenDelete+ serviceAccountCreate(input: ServiceAccountInput!): ServiceAccountCreate @deprecated(reason: "Use the `appCreate` mutation instead. This field will be removed after 2020-07-31.")+ serviceAccountUpdate(id: ID!, input: ServiceAccountInput!): ServiceAccountUpdate @deprecated(reason: "Use the `appUpdate` mutation instead. This field will be removed after 2020-07-31.")+ serviceAccountDelete(id: ID!): ServiceAccountDelete @deprecated(reason: "Use the `appDelete` mutation instead. This field will be removed after 2020-07-31.")- serviceAccountUpdatePrivateMetadata(id: ID!, input: MetaInput!): ServiceAccountUpdatePrivateMeta @deprecated(reason: "This field will be removed after 2020-07-31.Use the `UpdatePrivateMetadata` mutation with App instead.")- serviceAccountClearPrivateMetadata(id: ID!, input: MetaPath!): ServiceAccountClearPrivateMeta @deprecated(reason: "This field will be removed after 2020-07-31.Use the `DeletePrivateMetadata` mutation with App instead.")++ serviceAccountUpdatePrivateMetadata(id: ID!, input: MetaInput!): ServiceAccountUpdatePrivateMeta @deprecated(reason: "Use the `updatePrivateMetadata` mutation with App instead.This field will be removed after 2020-07-31.")++ serviceAccountClearPrivateMetadata(id: ID!, input: MetaPath!): ServiceAccountClearPrivateMeta @deprecated(reason: "Use the `DeletePrivateMetadata` mutation with App instead.This field will be removed after 2020-07-31.")+ serviceAccountTokenCreate(input: ServiceAccountTokenInput!): ServiceAccountTokenCreate @deprecated(reason: "Use the `appTokenCreate` mutation instead. This field will be removed after 2020-07-31.")+ serviceAccountTokenDelete(id: ID!): ServiceAccountTokenDelete @deprecated(reason: "Use the `appTokenDelete` mutation instead. This field will be removed after 2020-07-31.")permissionGroupCreate(input: PermissionGroupCreateInput!): PermissionGroupCreatepermissionGroupUpdate(id: ID!, input: PermissionGroupInput!): PermissionGroupUpdatepermissionGroupDelete(id: ID!): PermissionGroupDeletediff --cc saleor/webhook/migrations/0003_unmount_service_account.pyindex e047204135,0000000000..d2dc0c174emode 100644,000000..100644--- a/saleor/webhook/migrations/0003_unmount_service_account.py+++ b/saleor/webhook/migrations/0003_unmount_service_account.py@@@ -1,22 -1,0 +1,22 @@@+# Generated by Django 3.0.5 on 2020-04-16 06:01++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ("webhook", "0002_webhook_name"),- ("account", "0040_auto_20200416_0100"),++ ("account", "0041_auto_20200416_0100"),+ ]++ state_operations = [+ migrations.RemoveField(model_name="webhook", name="app",),+ ]++ operations = [+ migrations.RenameField(+ model_name="webhook", old_name="service_account", new_name="app"+ ),+ migrations.SeparateDatabaseAndState(state_operations=state_operations),+ ]diff --cc tests/api/pagination/test_account_service_account.pyindex 0000000000,c4f7518b93..7893017ffdmode 000000,100644..100644--- a/tests/api/pagination/test_account_service_account.py+++ b/tests/api/pagination/test_account_service_account.py@@@ -1,0 -1,105 +1,105 @@@+ import pytest+-from saleor.account.models import ServiceAccount++from saleor.app.models import App++ from ..utils import get_graphql_content+++ @pytest.fixture()+ def service_accounts_for_pagination():- service_accounts = ServiceAccount.objects.bulk_create(++ apps = App.objects.bulk_create(+ [- ServiceAccount(name="Account1", is_active=True),- ServiceAccount(name="AccountAccount1", is_active=True),- ServiceAccount(name="AccountAccount2", is_active=True),- ServiceAccount(name="Account2", is_active=True),- ServiceAccount(name="Account3", is_active=True),++ App(name="Account1", is_active=True),++ App(name="AccountAccount1", is_active=True),++ App(name="AccountAccount2", is_active=True),++ App(name="Account2", is_active=True),++ App(name="Account3", is_active=True),+ ]+ )- return service_accounts++ return apps+++ QUERY_SERVICE_ACCOUNT_PAGINATION = """+ query (+ $first: Int, $last: Int, $after: String, $before: String,+ $sortBy: ServiceAccountSortingInput, $filter: ServiceAccountFilterInput+ ){+ serviceAccounts(+ first: $first, last: $last, after: $after, before: $before,+ sortBy: $sortBy, filter: $filter+ ) {+ edges{+ node{+ name+ }+ }+ pageInfo{+ startCursor+ endCursor+ hasNextPage+ hasPreviousPage+ }+ }+ }+ """+++ @pytest.mark.parametrize(+ "sort_by, service_account_order",+ [+ ({"field": "NAME", "direction": "ASC"}, ["Account1", "Account2", "Account3"]),+ (+ {"field": "NAME", "direction": "DESC"},+ ["AccountAccount2", "AccountAccount1", "Account3"],+ ),+ ],+ )-def test_attributes_pagination_with_sorting(++def test_service_account_pagination_with_sorting(+ sort_by,+ service_account_order,+ staff_api_client,+ service_accounts_for_pagination,- permission_manage_service_accounts,++ permission_manage_apps,+ ):- staff_api_client.user.user_permissions.add(permission_manage_service_accounts)++ staff_api_client.user.user_permissions.add(permission_manage_apps)+ page_size = 3+ variables = {"first": page_size, "after": None, "sortBy": sort_by}+ response = staff_api_client.post_graphql(+ QUERY_SERVICE_ACCOUNT_PAGINATION, variables,+ )+ content = get_graphql_content(response)+ nodes = content["data"]["serviceAccounts"]["edges"]+ assert service_account_order[0] == nodes[0]["node"]["name"]+ assert service_account_order[1] == nodes[1]["node"]["name"]+ assert service_account_order[2] == nodes[2]["node"]["name"]+ assert len(nodes) == page_size+++ @pytest.mark.parametrize(+ "filter_by, service_account_order",+ [+ ({"search": "Account"}, ["Account1", "AccountAccount1"]),+ ({"search": "AccountAccount"}, ["AccountAccount1", "AccountAccount2"]),+ ({"search": "accountaccount"}, ["AccountAccount1", "AccountAccount2"]),+ ({"search": "Account1"}, ["Account1", "AccountAccount1"]),+ ],+ )-def test_attributes_pagination_with_filtering(++def test_service_account_pagination_with_filtering(+ filter_by,+ service_account_order,+ staff_api_client,+ service_accounts_for_pagination,- permission_manage_service_accounts,++ permission_manage_apps,+ ):- staff_api_client.user.user_permissions.add(permission_manage_service_accounts)++ staff_api_client.user.user_permissions.add(permission_manage_apps)+ page_size = 2+ variables = {"first": page_size, "after": None, "filter": filter_by}+ response = staff_api_client.post_graphql(+ QUERY_SERVICE_ACCOUNT_PAGINATION, variables,+ )+ content = get_graphql_content(response)++ nodes = content["data"]["serviceAccounts"]["edges"]+ assert service_account_order[0] == nodes[0]["node"]["name"]+ assert service_account_order[1] == nodes[1]["node"]["name"]+ assert len(nodes) == page_sizediff --cc tests/api/pagination/test_app.pyindex 0000000000,0000000000..4e8101d1b2new file mode 100644--- /dev/null+++ b/tests/api/pagination/test_app.py@@@ -1,0 -1,0 +1,97 @@@++import pytest++++from saleor.app.models import App++++from ..utils import get_graphql_content++++++def apps_for_pagination():++ apps = App.objects.bulk_create(++ [++ App(name="Account1", is_active=True),++ App(name="AccountAccount1", is_active=True),++ App(name="AccountAccount2", is_active=True),++ App(name="Account2", is_active=True),++ App(name="Account3", is_active=True),++ ]++ )++ return apps++++++QUERY_APP_PAGINATION = """++ query (++ $first: Int, $last: Int, $after: String, $before: String,++ $sortBy: AppSortingInput, $filter: AppFilterInput++ ){++ apps(++ first: $first, last: $last, after: $after, before: $before,++ sortBy: $sortBy, filter: $filter++ ) {++ edges{++ node{++ name++ }++ }++ pageInfo{++ startCursor++ endCursor++ hasNextPage++ hasPreviousPage++ }++ }++ }++"""++++++ "sort_by, apps_order",++ [++ ({"field": "NAME", "direction": "ASC"}, ["Account1", "Account2", "Account3"]),++ (++ {"field": "NAME", "direction": "DESC"},++ ["AccountAccount2", "AccountAccount1", "Account3"],++ ),++ ],++)++def test_apps_pagination_with_sorting(++ sort_by, apps_order, staff_api_client, apps_for_pagination, permission_manage_apps,++):++ staff_api_client.user.user_permissions.add(permission_manage_apps)++ page_size = 3++ variables = {"first": page_size, "after": None, "sortBy": sort_by}++ response = staff_api_client.post_graphql(QUERY_APP_PAGINATION, variables,)++ content = get_graphql_content(response)++ nodes = content["data"]["apps"]["edges"]++ assert apps_order[0] == nodes[0]["node"]["name"]++ assert apps_order[1] == nodes[1]["node"]["name"]++ assert apps_order[2] == nodes[2]["node"]["name"]++ assert len(nodes) == page_size++++++ "filter_by, apps_order",++ [++ ({"search": "Account"}, ["Account1", "AccountAccount1"]),++ ({"search": "AccountAccount"}, ["AccountAccount1", "AccountAccount2"]),++ ({"search": "accountaccount"}, ["AccountAccount1", "AccountAccount2"]),++ ({"search": "Account1"}, ["Account1", "AccountAccount1"]),++ ],++)++def test_apps_pagination_with_filtering(++ filter_by,++ apps_order,++ staff_api_client,++ apps_for_pagination,++ permission_manage_apps,++):++ staff_api_client.user.user_permissions.add(permission_manage_apps)++ page_size = 2++ variables = {"first": page_size, "after": None, "filter": filter_by}++ response = staff_api_client.post_graphql(QUERY_APP_PAGINATION, variables,)++ content = get_graphql_content(response)++++ nodes = content["data"]["apps"]["edges"]++ assert apps_order[0] == nodes[0]["node"]["name"]++ assert apps_order[1] == nodes[1]["node"]["name"]++ assert len(nodes) == page_sizediff --cc tests/api/test_checkout.pyindex aa6558e225,1a6909c55a..b0ed4b1cc6--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@@ -15,7 -15,7 +15,6 @@@ from saleor.checkout.models import Checfrom saleor.checkout.utils import clean_checkout, is_fully_paidfrom saleor.core.payments import PaymentInterfacefrom saleor.core.taxes import zero_money- from saleor.extensions.manager import ExtensionsManager-from saleor.plugins.manager import PluginsManagerfrom saleor.graphql.checkout.mutations import (clean_shipping_method,update_checkout_shipping_method_if_invalid,@@@ -23,6 -23,6 +22,7 @@@from saleor.order.models import Orderfrom saleor.payment import TransactionKindfrom saleor.payment.interface import GatewayResponse++from saleor.plugins.manager import PluginsManagerfrom saleor.shipping import ShippingMethodTypefrom saleor.shipping.models import ShippingMethodfrom saleor.warehouse.models import Stockdiff --cc tests/api/test_order.pyindex fa18144cc9,2330aed7e1..0f3087c693--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@@ -11,7 -11,7 +11,6 @@@ from prices import Money, TaxedMonefrom saleor.account.models import CustomerEventfrom saleor.core.permissions import OrderPermissionsfrom saleor.core.taxes import zero_taxed_money- from saleor.extensions.manager import ExtensionsManager-from saleor.plugins.manager import PluginsManagerfrom saleor.graphql.core.enums import ReportingPeriodfrom saleor.graphql.order.mutations.orders import (clean_order_cancel,@@@ -26,9 -26,10 +25,11 @@@ from saleor.order.error_codes import Orfrom saleor.order.models import Order, OrderEventfrom saleor.payment import ChargeStatus, CustomPaymentChoices, PaymentErrorfrom saleor.payment.models import Payment++from saleor.plugins.manager import PluginsManagerfrom saleor.shipping.models import ShippingMethod- from saleor.warehouse.models import Stock+ from saleor.warehouse.models import Allocation, Stock+ from ..utils import get_available_quantity_for_stockfrom .utils import assert_no_permission, get_graphql_contentdiff --cc tests/api/test_product.pyindex f452a9132f,a9b362a221..5507878b35--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@@ -111,10 -111,10 +111,10 @@@ def test_fetch_all_products(user_api_classert len(content["data"]["products"]["edges"]) == num_products--def test_fetch_all_products_service_account(- service_account_api_client, unavailable_product, permission_manage_products,++def test_fetch_all_products_app(+ app_api_client, unavailable_product, permission_manage_products,):- response = service_account_api_client.post_graphql(+ response = app_api_client.post_graphql(QUERY_FETCH_ALL_PRODUCTS,permissions=[permission_manage_products],check_no_permissions=False,diff --cc tests/plugins/test_webhook.pyindex a8cdd4fd21,65cf9b1f5d..4989ba6f66--- a/tests/plugins/test_webhook.py+++ b/tests/plugins/test_webhook.py@@@ -4,10 -4,10 +4,10 @@@ import pytesimport requestsfrom django.core.serializers import serialize-from saleor.account.models import ServiceAccount+from saleor.app.models import App- from saleor.extensions.manager import get_extensions_manager- from saleor.extensions.plugins.webhook import create_hmac_signature- from saleor.extensions.plugins.webhook.tasks import trigger_webhooks_for_event+ from saleor.plugins.manager import get_plugins_manager+ from saleor.plugins.webhook import create_hmac_signature+ from saleor.plugins.webhook.tasks import trigger_webhooks_for_eventfrom saleor.webhook.event_types import WebhookEventTypefrom saleor.webhook.payloads import (generate_checkout_payload,