swadhinbiswas

[email protected]
2026-07-29 14:08:06 +0600 committed NaN years ago
e77a06a
commit e77a06a
3 files changed
+23 -5
▼crates/justapi-py/tests/test_circuit_breaker_new.py
+7-1
32
32
def test_circuit_breaker():
33
33
p = multiprocessing.Process(target=run_server)
34
34
p.start()
35
- time.sleep(1.5) # Wait for server to start
35
+ # Wait for server to be ready with retry
36
+ for _ in range(20):
37
+ try:
38
+ urllib.request.urlopen("http://127.0.0.1:8088/ok", timeout=1)
39
+ break
40
+ except Exception:
41
+ time.sleep(0.5)
36
42
37
43
try:
38
44
# Request 1: fails, should return 500 (Python exception caught and mapped to 500)
39
45
▼crates/justapi-py/tests/test_query.py
+8-2
29
29
def server():
30
30
p = multiprocessing.Process(target=run_server)
31
31
p.start()
32
- time.sleep(1.5)
32
+ # Wait for server to be ready with retry
33
+ for _ in range(20):
34
+ try:
35
+ requests.get(f"http://127.0.0.1:{PORT}/hello", timeout=1)
36
+ break
37
+ except (requests.ConnectionError, requests.Timeout):
38
+ time.sleep(0.5)
33
39
try:
34
40
yield
35
41
finally:
36
42
p.terminate()
37
- p.join()
43
+ p.join(timeout=5)
38
44
39
45
40
46
def test_query_returns_body(server):
41
47
▼crates/justapi-py/tests/test_ws_sse.py
+8-2
44
44
def server():
45
45
p = multiprocessing.Process(target=run_server)
46
46
p.start()
47
- time.sleep(1.5)
47
+ # Wait for server to be ready with retry
48
+ for _ in range(20):
49
+ try:
50
+ requests.get(f"http://127.0.0.1:{PORT}/hello", timeout=1)
51
+ break
52
+ except (requests.ConnectionError, requests.Timeout):
53
+ time.sleep(0.5)
48
54
try:
49
55
yield
50
56
finally:
51
57
p.terminate()
52
- p.join()
58
+ p.join(timeout=5)
53
59
54
60
55
61
def test_sse_stream(server):
56
62