Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add resolver for ongoingAppsInstallation + tests
Maciej Korycinskif6114b663641
diff --git a/saleor/graphql/app/resolvers.py b/saleor/graphql/app/resolvers.pyindex a03e289f22..1200efb4f5 100644--- a/saleor/graphql/app/resolvers.py+++ b/saleor/graphql/app/resolvers.py@@ -1,5 +1,9 @@from ...app import models+def resolve_ongoing_apps_installations(info, **_kwargs):+ return models.AppJob.objects.all()++def resolve_apps(info, **_kwargs):return models.App.objects.all()diff --git a/saleor/graphql/app/schema.py b/saleor/graphql/app/schema.pyindex 2c536425fc..90710912e9 100644--- a/saleor/graphql/app/schema.py+++ b/saleor/graphql/app/schema.py@@ -15,7 +15,7 @@ from .mutations import (InstallApp,RetryInstallApp,)-from .resolvers import resolve_apps+from .resolvers import resolve_apps, resolve_ongoing_apps_installationsfrom .sorters import AppSortingInputfrom .types import App, OngoingAppInstallation@@ -41,6 +41,10 @@ class AppQueries(graphene.ObjectType):description="Look up a app by ID.",)+ @permission_required(AppPermission.MANAGE_APPS)+ def resolve_ongoing_apps_installations(self, info, **kwargs):+ return resolve_ongoing_apps_installations(info, **kwargs)+@permission_required(AppPermission.MANAGE_APPS)def resolve_apps(self, info, **kwargs):return resolve_apps(info, **kwargs)diff --git a/tests/api/app/queries/test_ongoing_apps_installations.py b/tests/api/app/queries/test_ongoing_apps_installations.pynew file mode 100644index 0000000000..fbf8325f38--- /dev/null+++ b/tests/api/app/queries/test_ongoing_apps_installations.py@@ -0,0 +1,42 @@+from tests.api.utils import assert_no_permission, get_graphql_content++ONGOING_APPS_INSTALLATION_QUERY = """+ {+ ongoingAppsInstallations{+ id+ }+ }+"""+++def test_ongoing_apps_installation(app_job, staff_api_client, permission_manage_apps):++ response = staff_api_client.post_graphql(+ ONGOING_APPS_INSTALLATION_QUERY, permissions=[permission_manage_apps]+ )+ content = get_graphql_content(response)+ installations = content["data"]["ongoingAppsInstallations"]+ assert len(installations) == 1+ assert int(installations[0]["id"]) == app_job.id+++def test_ongoing_apps_installation_by_app(+ app_job, app_api_client, permission_manage_apps+):+ response = app_api_client.post_graphql(+ ONGOING_APPS_INSTALLATION_QUERY, permissions=[permission_manage_apps]+ )+ content = get_graphql_content(response)+ installations = content["data"]["ongoingAppsInstallations"]+ assert len(installations) == 1+ assert int(installations[0]["id"]) == app_job.id+++def test_ongoing_apps_installation_by_app_missing_permission(app_job, app_api_client):+ response = app_api_client.post_graphql(ONGOING_APPS_INSTALLATION_QUERY)+ assert_no_permission(response)+++def test_ongoing_apps_installation_missing_permission(app_job, staff_api_client):+ response = staff_api_client.post_graphql(ONGOING_APPS_INSTALLATION_QUERY)+ assert_no_permission(response)