mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 13:31:27 +00:00
style: format files with black & rearrange imports
This commit is contained in:
parent
7e295f2e91
commit
aa2a7ff3aa
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue