mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
test(server): shim edge_tts.communicate so upstream WSS_URL monkey-patch imports in mock mode
Upstream's edge-tts workaround (msedgeservices 403 fix) now imports edge_tts.communicate explicitly; the conftest shim only registered the .exceptions submodule, so 4 tts tests failed after the sync. Same pattern as the existing opuslib_next submodule shims. Also widen CI + rebase gate from smoke-only to the full pytest suite and the unittest-only lifecycle tests (the smoke run masked these failures).
This commit is contained in:
parent
df6fc3ae76
commit
ffc331c467
3 changed files with 22 additions and 5 deletions
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
|
@ -33,10 +33,16 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pytest pytest-asyncio freezegun
|
pip install pytest pytest-asyncio freezegun
|
||||||
- name: Run smoke test
|
- name: Run tests
|
||||||
working-directory: main/xiaozhi-server
|
working-directory: main/xiaozhi-server
|
||||||
run: |
|
run: |
|
||||||
pytest tests/test_smoke.py -x -q
|
pytest tests/ -q
|
||||||
|
- name: Run unittest-only lifecycle tests
|
||||||
|
working-directory: main/xiaozhi-server
|
||||||
|
env:
|
||||||
|
PYTHONPATH: .
|
||||||
|
run: |
|
||||||
|
python3 -B -m unittest discover -s tests -p 'test_*lifecycle*.py'
|
||||||
|
|
||||||
java:
|
java:
|
||||||
name: Java (manager-api)
|
name: Java (manager-api)
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,13 @@ def _install_mock_layer() -> None:
|
||||||
shim.exceptions = _ShimModule(f"{name}.exceptions")
|
shim.exceptions = _ShimModule(f"{name}.exceptions")
|
||||||
sys.modules[name] = shim
|
sys.modules[name] = shim
|
||||||
sys.modules[f"{name}.exceptions"] = shim.exceptions
|
sys.modules[f"{name}.exceptions"] = shim.exceptions
|
||||||
|
if name == "edge_tts":
|
||||||
|
# core/providers/tts/edge.py imports edge_tts.communicate explicitly
|
||||||
|
# to monkey-patch WSS_URL; provide the submodule shim so the import
|
||||||
|
# resolves in mock mode (same pattern as opuslib_next above).
|
||||||
|
_comm = _ShimModule(f"{name}.communicate")
|
||||||
|
shim.communicate = _comm
|
||||||
|
sys.modules[f"{name}.communicate"] = _comm
|
||||||
|
|
||||||
# Shorten asyncio.sleep to prevent retry loops from delaying execution.
|
# Shorten asyncio.sleep to prevent retry loops from delaying execution.
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,14 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v python3 >/dev/null 2>&1 && python3 -c 'import pytest' >/dev/null 2>&1; then
|
if command -v python3 >/dev/null 2>&1 && python3 -c 'import pytest' >/dev/null 2>&1; then
|
||||||
( cd main/xiaozhi-server && PYTHONPATH=. pytest tests/test_smoke.py -q ) \
|
( cd main/xiaozhi-server && PYTHONPATH=. pytest tests/ -q ) \
|
||||||
&& echo "--- PASS: python smoke" || { echo "--- FAIL: python smoke"; fail=1; }
|
&& echo "--- PASS: python tests" || { echo "--- FAIL: python tests"; fail=1; }
|
||||||
|
# Upstream ships unittest-only lifecycle tests (excluded from pytest via
|
||||||
|
# __test__ = False); run them explicitly.
|
||||||
|
( cd main/xiaozhi-server && PYTHONPATH=. python3 -B -m unittest discover -s tests -p 'test_*lifecycle*.py' ) \
|
||||||
|
&& echo "--- PASS: python lifecycle tests" || { echo "--- FAIL: python lifecycle tests"; fail=1; }
|
||||||
else
|
else
|
||||||
echo "==> pytest not present - skipping python smoke"
|
echo "==> pytest not present - skipping python tests"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue