Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Refactored implicit package import to explicit
Mikail KOCAKb76c41c07b9e
diff --git a/saleor/graphql/middleware.py b/saleor/graphql/middleware.pyindex 30cfd77eeb..f08f509d71 100644--- a/saleor/graphql/middleware.py+++ b/saleor/graphql/middleware.py@@ -1,7 +1,7 @@from typing import Optionalimport opentracing as ot-import opentracing.tags+import opentracing.tags as ot_tagsfrom django.conf import settingsfrom django.contrib.auth.models import AnonymousUserfrom 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.pyindex 788c781c03..15e2889911 100644--- a/saleor/graphql/views.py+++ b/saleor/graphql/views.py@@ -4,8 +4,7 @@ import tracebackfrom typing import Any, Dict, List, Optional, Tuple, Unionimport opentracing as ot-import opentracing.logs-import opentracing.tags+import opentracing.tags as ot_tagsfrom django.conf import settingsfrom django.db import connectionfrom 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_codedef get_root_value(self):diff --git a/saleor/settings.py b/saleor/settings.pyindex 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", 50TEST_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.pyindex 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_onresponse = 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 == statusdef test_graphql_view_options(client):