From aa2a7ff3aacce987ff3f9e26e2017ac3a9697233 Mon Sep 17 00:00:00 2001 From: nhnn Date: Wed, 10 Jul 2024 15:53:56 +0300 Subject: [PATCH] style: format files with black & rearrange imports --- selfprivacy_api/graphql/queries/monitoring.py | 12 +++++++++--- selfprivacy_api/utils/prometheus.py | 4 +++- tests/test_graphql/test_api_monitoring.py | 13 ++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/selfprivacy_api/graphql/queries/monitoring.py b/selfprivacy_api/graphql/queries/monitoring.py index 3b79692..adf5556 100644 --- a/selfprivacy_api/graphql/queries/monitoring.py +++ b/selfprivacy_api/graphql/queries/monitoring.py @@ -6,13 +6,19 @@ from selfprivacy_api.utils.prometheus import PrometheusQueries, PrometheusQueryR @strawberry.type class Monitoring: @strawberry.field - def disk_usage(start: Optional[int] = None, end: Optional[int] = None, step: int = 60) -> PrometheusQueryResult: + def disk_usage( + start: Optional[int] = None, end: Optional[int] = None, step: int = 60 + ) -> PrometheusQueryResult: return PrometheusQueries.disk_usage(start, end, step) @strawberry.field - def memory_usage(start: Optional[int] = None, end: Optional[int] = None, step: int = 60) -> PrometheusQueryResult: + def memory_usage( + start: Optional[int] = None, end: Optional[int] = None, step: int = 60 + ) -> PrometheusQueryResult: return PrometheusQueries.memory_usage(start, end, step) @strawberry.field - def cpu_usage(start: Optional[int] = None, end: Optional[int] = None, step: int = 60) -> PrometheusQueryResult: + def cpu_usage( + start: Optional[int] = None, end: Optional[int] = None, step: int = 60 + ) -> PrometheusQueryResult: return PrometheusQueries.cpu_usage(start, end, step) diff --git a/selfprivacy_api/utils/prometheus.py b/selfprivacy_api/utils/prometheus.py index a62b93f..e4c2dc2 100644 --- a/selfprivacy_api/utils/prometheus.py +++ b/selfprivacy_api/utils/prometheus.py @@ -2,10 +2,12 @@ # pylint: disable=too-few-public-methods import requests + import strawberry +from strawberry.scalars import JSON + from dataclasses import dataclass from typing import Optional -from strawberry.scalars import JSON from datetime import datetime, timedelta PROMETHEUS_URL = "http://localhost:9001" diff --git a/tests/test_graphql/test_api_monitoring.py b/tests/test_graphql/test_api_monitoring.py index ba3f2fb..0d386a2 100644 --- a/tests/test_graphql/test_api_monitoring.py +++ b/tests/test_graphql/test_api_monitoring.py @@ -3,6 +3,7 @@ # pylint: disable=missing-function-docstring import pytest + from selfprivacy_api.utils.prometheus import PrometheusQueryResult from tests.test_graphql.common import ( assert_empty, @@ -83,7 +84,9 @@ def prometheus_result_from_dict(dict): def mock_cpu_usage(mocker): mock = mocker.patch( "selfprivacy_api.utils.prometheus.PrometheusQueries._send_query", - return_value=prometheus_result_from_dict(MOCK_CPU_USAGE_RESPONSE["data"]["monitoring"]["cpuUsage"]), + return_value=prometheus_result_from_dict( + MOCK_CPU_USAGE_RESPONSE["data"]["monitoring"]["cpuUsage"] + ), ) return mock @@ -92,7 +95,9 @@ def mock_cpu_usage(mocker): def mock_memory_usage(mocker): mock = mocker.patch( "selfprivacy_api.utils.prometheus.PrometheusQueries._send_query", - return_value=prometheus_result_from_dict(MOCK_MEMORY_USAGE_RESPONSE["data"]["monitoring"]["memoryUsage"]), + return_value=prometheus_result_from_dict( + MOCK_MEMORY_USAGE_RESPONSE["data"]["monitoring"]["memoryUsage"] + ), ) return mock @@ -101,7 +106,9 @@ def mock_memory_usage(mocker): def mock_disk_usage(mocker): mock = mocker.patch( "selfprivacy_api.utils.prometheus.PrometheusQueries._send_query", - return_value=prometheus_result_from_dict(MOCK_DISK_USAGE_RESPONSE["data"]["monitoring"]["diskUsage"]), + return_value=prometheus_result_from_dict( + MOCK_DISK_USAGE_RESPONSE["data"]["monitoring"]["diskUsage"] + ), ) return mock