mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 20:11:30 +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
|
@strawberry.type
|
||||||
class Monitoring:
|
class Monitoring:
|
||||||
@strawberry.field
|
@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)
|
return PrometheusQueries.disk_usage(start, end, step)
|
||||||
|
|
||||||
@strawberry.field
|
@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)
|
return PrometheusQueries.memory_usage(start, end, step)
|
||||||
|
|
||||||
@strawberry.field
|
@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)
|
return PrometheusQueries.cpu_usage(start, end, step)
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import strawberry
|
import strawberry
|
||||||
|
from strawberry.scalars import JSON
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from strawberry.scalars import JSON
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
PROMETHEUS_URL = "http://localhost:9001"
|
PROMETHEUS_URL = "http://localhost:9001"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# pylint: disable=missing-function-docstring
|
# pylint: disable=missing-function-docstring
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from selfprivacy_api.utils.prometheus import PrometheusQueryResult
|
from selfprivacy_api.utils.prometheus import PrometheusQueryResult
|
||||||
from tests.test_graphql.common import (
|
from tests.test_graphql.common import (
|
||||||
assert_empty,
|
assert_empty,
|
||||||
|
@ -83,7 +84,9 @@ def prometheus_result_from_dict(dict):
|
||||||
def mock_cpu_usage(mocker):
|
def mock_cpu_usage(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
"selfprivacy_api.utils.prometheus.PrometheusQueries._send_query",
|
"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
|
return mock
|
||||||
|
|
||||||
|
@ -92,7 +95,9 @@ def mock_cpu_usage(mocker):
|
||||||
def mock_memory_usage(mocker):
|
def mock_memory_usage(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
"selfprivacy_api.utils.prometheus.PrometheusQueries._send_query",
|
"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
|
return mock
|
||||||
|
|
||||||
|
@ -101,7 +106,9 @@ def mock_memory_usage(mocker):
|
||||||
def mock_disk_usage(mocker):
|
def mock_disk_usage(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
"selfprivacy_api.utils.prometheus.PrometheusQueries._send_query",
|
"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
|
return mock
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue