Compare commits

..

No commits in common. "52e2c26304a4f45fd9afe0f43015596f98358a9d" and "ad6c1edf80648215aab3db79bf8322d9101de279" have entirely different histories.

View File

@ -1,6 +1,7 @@
import asyncio
import json
import subprocess
import time
from pathlib import Path
import httpx
@ -274,8 +275,6 @@ async def test_recap_time_logging_attempts_multiple_entries_with_bounded_concurr
active = 0
peak = 0
attempted = []
first_wave_started = asyncio.Event()
release_first_wave = asyncio.Event()
async def user():
return {"id": 1, "login": "Timmy"}
@ -285,10 +284,8 @@ async def test_recap_time_logging_attempts_multiple_entries_with_bounded_concurr
active += 1
peak = max(peak, active)
attempted.append(identity)
if len(attempted) == 3:
first_wave_started.set()
try:
await release_first_wave.wait()
await asyncio.sleep(0.1)
finally:
active -= 1
@ -308,24 +305,17 @@ async def test_recap_time_logging_attempts_multiple_entries_with_bounded_concurr
await client.post("/api/v1/session", json={"access_token": "correct horse battery staple"})
headers = {"Origin": "https://test", "X-CSRF-Token": client.cookies["stackchain_csrf"]}
grant = await recap_time_grant(client, headers, payload)
request = asyncio.create_task(
client.post(
started = time.perf_counter()
response = await client.post(
"/api/v1/today/recaps/log-time",
json=payload,
headers={**headers, "X-Step-Up-Grant": grant},
)
)
await asyncio.wait_for(first_wave_started.wait(), timeout=1)
await asyncio.sleep(0)
assert active == 3
assert peak == 3
assert len(attempted) == 3
assert not request.done()
release_first_wave.set()
response = await request
elapsed = time.perf_counter() - started
assert response.status_code == 200
assert peak == 3
assert elapsed < 0.35
assert 1 < peak <= 3
assert set(attempted) == set(identities)
assert response.json()["time_logs"] == [
{"identity": identity, "status": "logged"} for identity in identities