Minor ruff fixes in integration tests

This commit is contained in:
Donkie
2023-07-10 11:21:36 +02:00
parent 5654b5d7bc
commit 34257869ba
3 changed files with 11 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ repos:
- id: black - id: black
args: ["--check"] args: ["--check"]
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.270 rev: v0.0.277
hooks: hooks:
- id: ruff - id: ruff
args: ["--target-version", "py39"] args: ["--target-version", "py39"]

View File

@@ -3,7 +3,7 @@
import math import math
import os import os
import time import time
from enum import Enum from enum import StrEnum
from typing import Any from typing import Any
import httpx import httpx
@@ -14,7 +14,7 @@ TIMEOUT = 10
URL = "http://spoolman:8000" URL = "http://spoolman:8000"
class DbType(str, Enum): class DbType(StrEnum):
"""Enum for database types.""" """Enum for database types."""
SQLITE = "sqlite" SQLITE = "sqlite"
@@ -43,7 +43,7 @@ def _wait_for_server(): # noqa: ANN202
try: try:
response = httpx.get("http://spoolman:8000", timeout=1) response = httpx.get("http://spoolman:8000", timeout=1)
response.raise_for_status() response.raise_for_status()
except httpx.HTTPError: except httpx.HTTPError: # noqa: PERF203
if time.time() - start_time > TIMEOUT: if time.time() - start_time > TIMEOUT:
raise raise
else: else:

View File

@@ -225,7 +225,7 @@ def test_get_spool_not_found():
assert "123456789" in message assert "123456789" in message
def test_find_spools(random_filament: dict[str, Any]): # noqa: PLR0915 def test_find_spools(random_filament: dict[str, Any]):
"""Test finding spools in the database.""" """Test finding spools in the database."""
# Setup # Setup
result = httpx.post( result = httpx.post(
@@ -628,18 +628,18 @@ async def test_use_spool_concurrent(random_filament: dict[str, Any]):
requests = 100 requests = 100
used_weight = 0.5 used_weight = 0.5
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
tasks = [] await asyncio.gather(
for _ in range(requests): *(
tasks.append(
client.put( client.put(
f"{URL}/api/v1/spool/{spool['id']}/use", f"{URL}/api/v1/spool/{spool['id']}/use",
json={ json={
"use_weight": used_weight, "use_weight": used_weight,
}, },
timeout=60, timeout=60,
), )
) for _ in range(requests)
await asyncio.gather(*tasks) ),
)
# Verify # Verify
result = httpx.get(f"{URL}/api/v1/spool/{spool['id']}") # noqa: ASYNC100 result = httpx.get(f"{URL}/api/v1/spool/{spool['id']}") # noqa: ASYNC100