mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2026-02-21 18:50:08 -05:00
Add Chinese variant fallback tests
Co-authored-by: pierotofy <1951843+pierotofy@users.noreply.github.com>
This commit is contained in:
parent
05e09f577b
commit
ecb88388ee
@ -29,6 +29,30 @@ def client_with_pt(app_with_pt):
|
||||
return app_with_pt.test_client()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app_with_zh():
|
||||
sys.argv = ['', '--load-only', 'en,zh']
|
||||
app = create_app(get_args())
|
||||
yield app
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client_with_zh(app_with_zh):
|
||||
return app_with_zh.test_client()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app_with_zt():
|
||||
sys.argv = ['', '--load-only', 'en,zt']
|
||||
app = create_app(get_args())
|
||||
yield app
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client_with_zt(app_with_zt):
|
||||
return app_with_zt.test_client()
|
||||
|
||||
|
||||
def test_auto_detect_fallback_pt_to_pb(client_with_pb):
|
||||
response = client_with_pb.post("/translate", data={
|
||||
"q": "Olá mundo",
|
||||
@ -69,3 +93,31 @@ def test_explicit_language_no_fallback(client_with_pb):
|
||||
assert response.status_code == 400
|
||||
assert "error" in response_json
|
||||
|
||||
|
||||
def test_auto_detect_fallback_zt_to_zh(client_with_zh):
|
||||
response = client_with_zh.post("/translate", data={
|
||||
"q": "你好世界",
|
||||
"source": "auto",
|
||||
"target": "en",
|
||||
"format": "text"
|
||||
})
|
||||
|
||||
response_json = json.loads(response.data)
|
||||
assert response.status_code == 200
|
||||
assert "translatedText" in response_json
|
||||
assert len(response_json["translatedText"]) > 0
|
||||
|
||||
|
||||
def test_auto_detect_fallback_zh_to_zt(client_with_zt):
|
||||
response = client_with_zt.post("/translate", data={
|
||||
"q": "你好世界",
|
||||
"source": "auto",
|
||||
"target": "en",
|
||||
"format": "text"
|
||||
})
|
||||
|
||||
response_json = json.loads(response.data)
|
||||
assert response.status_code == 200
|
||||
assert "translatedText" in response_json
|
||||
assert len(response_json["translatedText"]) > 0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user