Skip to content

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

Refactored implicit package import to explicit

Mikail KOCAKb76c41c07b9e
diff --git a/saleor/graphql/middleware.py b/saleor/graphql/middleware.py
index 30cfd77eeb..f08f509d71 100644
--- a/saleor/graphql/middleware.py
+++ b/saleor/graphql/middleware.py
@@ -1,7 +1,7 @@
from typing import Optional
import opentracing as ot
-import opentracing.tags
+import opentracing.tags as ot_tags
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.utils.functional import SimpleLazyObject
@@ -51,7 +51,7 @@ class OpentracingGrapheneMiddleware:
operation_name=info.operation.operation
) as scope:
span = scope.span
- span.set_tag(ot.tags.COMPONENT, "graphql")
+ span.set_tag(ot_tags.COMPONENT, "graphql")
span.set_tag("graphql.parent_type", info.parent_type.name)
span.set_tag("graphql.field_name", info.field_name)
return next(root, info, **kwargs)
diff --git a/saleor/graphql/views.py b/saleor/graphql/views.py
index 788c781c03..15e2889911 100644
--- a/saleor/graphql/views.py
+++ b/saleor/graphql/views.py
@@ -4,8 +4,7 @@ import traceback
from typing import Any, Dict, List, Optional, Tuple, Union
import opentracing as ot
-import opentracing.logs
-import opentracing.tags
+import opentracing.tags as ot_tags
from django.conf import settings
from django.db import connection
from django.http import HttpRequest, HttpResponseNotAllowed, JsonResponse
@@ -33,8 +32,8 @@ handled_errors_logger = logging.getLogger("saleor.graphql.errors.handled")
def tracing_wrapper(execute, sql, params, many, context):
with ot.global_tracer().start_active_span(operation_name="query") as scope:
span = scope.span
- span.set_tag(ot.tags.COMPONENT, "db")
- span.set_tag(ot.tags.DATABASE_STATEMENT, sql)
+ span.set_tag(ot_tags.COMPONENT, "db")
+ span.set_tag(ot_tags.DATABASE_STATEMENT, sql)
return execute(sql, params, many, context)
@@ -117,9 +116,9 @@ class GraphQLView(View):
) -> Tuple[Optional[Dict[str, List[Any]]], int]:
with ot.global_tracer().start_active_span(operation_name="request") as scope:
span = scope.span
- span.set_tag(ot.tags.COMPONENT, "http")
- span.set_tag(ot.tags.HTTP_METHOD, request.method)
- span.set_tag(ot.tags.HTTP_URL, request.get_full_path())
+ span.set_tag(ot_tags.COMPONENT, "http")
+ span.set_tag(ot_tags.HTTP_METHOD, request.method)
+ span.set_tag(ot_tags.HTTP_URL, request.get_full_path())
execution_result = self.execute_graphql_request(request, data)
status_code = 200
@@ -137,7 +136,7 @@ class GraphQLView(View):
else:
result = None
- span.set_tag(ot.tags.HTTP_STATUS_CODE, status_code)
+ span.set_tag(ot_tags.HTTP_STATUS_CODE, status_code)
return result, status_code
def get_root_value(self):
diff --git a/saleor/settings.py b/saleor/settings.py
index 3f7e4ba721..81f4d4965d 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -389,7 +389,7 @@ MAX_CHECKOUT_LINE_QUANTITY = int(os.environ.get("MAX_CHECKOUT_LINE_QUANTITY", 50
TEST_RUNNER = "tests.runner.PytestTestRunner"
-PLAYGROUND_ENABLED = get_bool_from_env("PLAYGROUND_ENABLED", DEBUG)
+PLAYGROUND_ENABLED = get_bool_from_env("PLAYGROUND_ENABLED", True)
ALLOWED_HOSTS = get_list(os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1"))
ALLOWED_GRAPHQL_ORIGINS = os.environ.get("ALLOWED_GRAPHQL_ORIGINS", "*")
diff --git a/tests/api/test_view.py b/tests/api/test_view.py
index 7d80c329da..f66001dccf 100644
--- a/tests/api/test_view.py
+++ b/tests/api/test_view.py
@@ -52,14 +52,11 @@ def test_batch_queries(category, product, api_client):
assert data["category"]["name"] == category.name
-def test_graphql_view_get_enabled_or_disabled(client, settings):
- settings.PLAYGROUND_ENABLED = False
[email protected]("playground_on, status", [(True, 200), (False, 405)])
+def test_graphql_view_get_enabled_or_disabled(client, settings, playground_on, status):
+ settings.PLAYGROUND_ENABLED = playground_on
response = client.get(API_PATH)
- assert response.status_code == 405
-
- settings.PLAYGROUND_ENABLED = True
- response = client.get(API_PATH)
- assert response.status_code == 200
+ assert response.status_code == status
def test_graphql_view_options(client):