Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2024
1 parent 323b7f5 commit b866ec5
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 67 deletions.
38 changes: 19 additions & 19 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
loop.close()


@pytest.fixture()
@pytest.fixture
def platform_auth_server(docker_ip: str, docker_services: Services) -> URL:
port = docker_services.port_for("platform-auth", 8080)
return URL(f"http://{docker_ip}:{port}")


@pytest.fixture()
@pytest.fixture
async def platform_api_server(
unused_tcp_port_factory: Callable[[], int],
platform_api_app: aiohttp.web.Application,
Expand All @@ -91,7 +91,7 @@ async def platform_api_server(
yield URL.build(scheme="http", host=address.host, port=address.port)


@pytest.fixture()
@pytest.fixture
async def platform_config_server(
unused_tcp_port_factory: Callable[[], int],
platform_config_app: aiohttp.web.Application,
Expand All @@ -102,14 +102,14 @@ async def platform_config_server(
yield URL.build(scheme="http", host=address.host, port=address.port)


@pytest.fixture()
@pytest.fixture
def platform_auth_config(
platform_auth_server: URL, service_token: str
) -> PlatformAuthConfig:
return PlatformAuthConfig(url=platform_auth_server, token=service_token)


@pytest.fixture()
@pytest.fixture
def platform_api_config(
platform_api_server: URL, service_token: str
) -> PlatformServiceConfig:
Expand All @@ -118,14 +118,14 @@ def platform_api_config(
)


@pytest.fixture()
@pytest.fixture
def platform_config_config(
platform_config_server: URL, service_token: str
) -> PlatformServiceConfig:
return PlatformServiceConfig(url=platform_config_server, token=service_token)


@pytest.fixture()
@pytest.fixture
def metrics_exporter_config(
unused_tcp_port_factory: Callable[[], int],
platform_config_config: PlatformServiceConfig,
Expand All @@ -143,7 +143,7 @@ def metrics_exporter_config(
)


@pytest.fixture()
@pytest.fixture
async def metrics_exporter_server_factory() -> (
Callable[[MetricsExporterConfig], AbstractAsyncContextManager[URL]]
):
Expand All @@ -160,7 +160,7 @@ async def _create(
return _create


@pytest.fixture()
@pytest.fixture
async def metrics_exporter_server(
metrics_exporter_server_factory: Callable[
[MetricsExporterConfig], AbstractAsyncContextManager[URL]
Expand All @@ -171,13 +171,13 @@ async def metrics_exporter_server(
yield server


@pytest.fixture()
@pytest.fixture
def thanos_query_url(docker_ip: str, docker_services: Services) -> URL:
port = docker_services.port_for("thanos-query", 9091)
return URL(f"http://{docker_ip}:{port}")


@pytest.fixture()
@pytest.fixture
def prometheus_proxy_config(
unused_tcp_port_factory: Callable[[], int],
platform_auth_config: PlatformAuthConfig,
Expand All @@ -194,7 +194,7 @@ def prometheus_proxy_config(
)


@pytest.fixture()
@pytest.fixture
async def prometheus_proxy_server(
prometheus_proxy_config: PrometheusProxyConfig,
) -> AsyncIterator[URL]:
Expand All @@ -205,13 +205,13 @@ async def prometheus_proxy_server(
yield URL.build(scheme="http", host=address.host, port=address.port)


@pytest.fixture()
@pytest.fixture
def grafana_url(docker_ip: str, docker_services: Services) -> URL:
port = docker_services.port_for("grafana", 3000)
return URL(f"http://{docker_ip}:{port}")


@pytest.fixture()
@pytest.fixture
def grafana_proxy_config(
unused_tcp_port_factory: Callable[[], int],
platform_auth_config: PlatformAuthConfig,
Expand All @@ -228,7 +228,7 @@ def grafana_proxy_config(
)


@pytest.fixture()
@pytest.fixture
async def grafana_proxy_server(
grafana_proxy_config: GrafanaProxyConfig,
) -> AsyncIterator[URL]:
Expand All @@ -239,13 +239,13 @@ async def grafana_proxy_server(
yield URL.build(scheme="http", host=address.host, port=address.port)


@pytest.fixture()
@pytest.fixture
async def client() -> AsyncIterator[aiohttp.ClientSession]:
async with aiohttp.ClientSession() as session:
yield session


@pytest.fixture()
@pytest.fixture
def metrics_api_config(
unused_tcp_port_factory: Callable[[], int],
platform_auth_config: PlatformAuthConfig,
Expand All @@ -264,7 +264,7 @@ def metrics_api_config(
)


@pytest.fixture()
@pytest.fixture
async def metrics_api_server(
metrics_api_config: MetricsApiConfig,
) -> AsyncIterator[URL]:
Expand All @@ -275,7 +275,7 @@ async def metrics_api_server(
yield address.http_url


@pytest.fixture()
@pytest.fixture
async def exit_stack() -> AsyncIterator[AsyncExitStack]:
async with AsyncExitStack() as stack:
yield stack
2 changes: 1 addition & 1 deletion tests/integration/conftest_kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def __call__(
pass


@pytest.fixture()
@pytest.fixture
async def kube_pod_factory(kube_client: KubeClient) -> AsyncIterator[KubePodFactory]:
pods = []

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest_platform_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def platform_api_app() -> aiohttp.web.Application:
async def _get_config(request: aiohttp.web.Request) -> aiohttp.web.Response:
return aiohttp.web.json_response(
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/conftest_platform_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
_JWT_SECRET = "secret"


@pytest.fixture()
@pytest.fixture
def token_factory() -> Callable[[str], str]:
def _create(name: str) -> str:
payload = {"https://platform.neuromation.io/user": name}
Expand All @@ -30,7 +30,7 @@ class User(AuthUser):
UserFactory = Callable[[str, Sequence[Permission]], Awaitable[User]]


@pytest.fixture()
@pytest.fixture
def user_factory(
token_factory: Callable[[str], str], platform_auth_server: URL
) -> UserFactory:
Expand All @@ -50,15 +50,15 @@ async def _create(name: str, permissions: Sequence[Permission] = ()) -> User:
return _create


@pytest.fixture()
@pytest.fixture
async def service_token(
user_factory: UserFactory, token_factory: Callable[[str], str]
) -> str:
await user_factory("cluster", [Permission(uri="user://", action="read")])
return token_factory("cluster")


@pytest.fixture()
@pytest.fixture
async def cluster_admin_token(user_factory: UserFactory) -> str:
user = await user_factory(
"cluster-admin",
Expand All @@ -70,7 +70,7 @@ async def cluster_admin_token(user_factory: UserFactory) -> str:
return user.token


@pytest.fixture()
@pytest.fixture
async def regular_user_token(user_factory: UserFactory) -> str:
user = await user_factory(
"user",
Expand All @@ -82,7 +82,7 @@ async def regular_user_token(user_factory: UserFactory) -> str:
return user.token


@pytest.fixture()
@pytest.fixture
async def other_cluster_user_token(user_factory: UserFactory) -> str:
user = await user_factory(
"other-user",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest_platform_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from neuro_config_client.factories import NodeRole


@pytest.fixture()
@pytest.fixture
def platform_config_app() -> aiohttp.web.Application:
async def _get_cluster(request: aiohttp.web.Request) -> aiohttp.web.Response:
name = request.match_info["cluster_name"]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ async def test_dashboard_forbidden(


class TestMetricsApi:
@pytest.fixture()
@pytest.fixture
async def user(self, user_factory: UserFactory) -> User:
return await user_factory(
str(uuid.uuid4()), [Permission("cluster://default", "read")]
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_kube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class TestKubeClientTokenUpdater:
@pytest.fixture()
@pytest.fixture
async def kube_app(self) -> aiohttp.web.Application:
async def _get_pods(request: aiohttp.web.Request) -> aiohttp.web.Response:
auth = request.headers["Authorization"]
Expand All @@ -33,7 +33,7 @@ async def _get_pods(request: aiohttp.web.Request) -> aiohttp.web.Response:
)
return app

@pytest.fixture()
@pytest.fixture
async def kube_server(
self, kube_app: aiohttp.web.Application, unused_tcp_port_factory: Any
) -> AsyncIterator[str]:
Expand All @@ -42,14 +42,14 @@ async def kube_server(
) as address:
yield f"http://{address.host}:{address.port}"

@pytest.fixture()
@pytest.fixture
def kube_token_path(self) -> Iterator[str]:
_, path = tempfile.mkstemp()
Path(path).write_text("token-1")
yield path
Path(path).unlink()

@pytest.fixture()
@pytest.fixture
async def kube_client(
self, kube_server: str, kube_token_path: str
) -> AsyncIterator[KubeClient]:
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def cluster(self) -> Cluster:
return self._cluster


@pytest.fixture()
@pytest.fixture
def cluster() -> Cluster:
return Cluster(
name="default",
Expand All @@ -50,13 +50,13 @@ def cluster() -> Cluster:
)


@pytest.fixture()
@pytest.fixture
def cluster_holder(cluster: Cluster) -> ClusterHolder:
return _TestClusterHolder(cluster)


class TestPodCreditsCollector:
@pytest.fixture()
@pytest.fixture
def collector(
self, kube_client: KubeClient, kube_node: Node, cluster_holder: ClusterHolder
) -> PodCreditsCollector:
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_metrics_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ async def _post_query_range(
return aiohttp.web.json_response({})


@pytest.fixture()
@pytest.fixture
def prometheus_handler() -> PrometheusHandler:
return PrometheusHandler()


@pytest.fixture()
@pytest.fixture
def prometheus_app(prometheus_handler: PrometheusHandler) -> aiohttp.web.Application:
app = aiohttp.web.Application()
app.router.add_post("/api/v1/query_range", prometheus_handler.do_post_query_range)
return app


@pytest.fixture()
@pytest.fixture
async def prometheus_test_client(
aiohttp_client: Callable[[aiohttp.web.Application], Awaitable[TestClient]],
prometheus_app: aiohttp.web.Application,
) -> TestClient:
return await aiohttp_client(prometheus_app)


@pytest.fixture()
@pytest.fixture
def prometheus_client(
prometheus_test_client: TestClient,
) -> PrometheusClient:
Expand All @@ -73,7 +73,7 @@ def cluster(self) -> Cluster:
return self._cluster


@pytest.fixture()
@pytest.fixture
def cluster() -> Cluster:
return Cluster(
name="default",
Expand All @@ -89,7 +89,7 @@ def cluster() -> Cluster:


class TestMetricsService:
@pytest.fixture()
@pytest.fixture
def metrics_service(
self, prometheus_client: PrometheusClient, cluster: Cluster
) -> MetricsService:
Expand Down
Loading

0 comments on commit b866ec5

Please sign in to comment.