test(api): stabilize vedastro timeout coverage
This commit is contained in:
@@ -7,6 +7,7 @@ import base64
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
@@ -2520,8 +2521,10 @@ def test_consultation_foreground_times_out_vedastro_without_failing_local(monkey
|
||||
'themes': {},
|
||||
})
|
||||
|
||||
release_gateway = threading.Event()
|
||||
|
||||
def slow_gateway(body):
|
||||
time.sleep(0.4)
|
||||
release_gateway.wait(timeout=2)
|
||||
return {
|
||||
'scope': 'vedastro_gateway_run',
|
||||
'status': 'official_verified',
|
||||
@@ -2531,20 +2534,23 @@ def test_consultation_foreground_times_out_vedastro_without_failing_local(monkey
|
||||
|
||||
monkeypatch.setattr(handler, '_compute_vedastro_gateway_run', slow_gateway)
|
||||
|
||||
result = handler._compute_consultation_workflow({
|
||||
'entry_mode': 'direct_chart',
|
||||
'question': '应期与阶段问题:深入看今日',
|
||||
'theme': ['career'],
|
||||
'year': 1997,
|
||||
'month': 8,
|
||||
'day': 8,
|
||||
'hour': 5,
|
||||
'minute': 0,
|
||||
'lat': 36.420487,
|
||||
'lon': 114.209936,
|
||||
'tz': 8,
|
||||
'defer_optional_external_evidence': True,
|
||||
})
|
||||
try:
|
||||
result = handler._compute_consultation_workflow({
|
||||
'entry_mode': 'direct_chart',
|
||||
'question': '应期与阶段问题:深入看今日',
|
||||
'theme': ['career'],
|
||||
'year': 1997,
|
||||
'month': 8,
|
||||
'day': 8,
|
||||
'hour': 5,
|
||||
'minute': 0,
|
||||
'lat': 36.420487,
|
||||
'lon': 114.209936,
|
||||
'tz': 8,
|
||||
'defer_optional_external_evidence': True,
|
||||
})
|
||||
finally:
|
||||
release_gateway.set()
|
||||
|
||||
assert result['success'] is True
|
||||
assert result['vedastro_gateway']['official_closure_reason'] == 'foreground_optional_evidence_timeout'
|
||||
|
||||
Reference in New Issue
Block a user