mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2026-04-08 02:01:54 -04:00
Add integration tests for Portuguese language variant fallback
Co-authored-by: pierotofy <1951843+pierotofy@users.noreply.github.com>
This commit is contained in:
parent
83cc8dd7b8
commit
533643d8e5
@ -0,0 +1,50 @@
|
||||
import sys
|
||||
import pytest
|
||||
from libretranslate.app import create_app
|
||||
from libretranslate.main import get_args
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app_with_pb():
|
||||
sys.argv = ['', '--load-only', 'en,pb']
|
||||
app = create_app(get_args())
|
||||
yield app
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client_with_pb(app_with_pb):
|
||||
return app_with_pb.test_client()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def app_with_pt():
|
||||
sys.argv = ['', '--load-only', 'en,pt']
|
||||
app = create_app(get_args())
|
||||
yield app
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client_with_pt(app_with_pt):
|
||||
return app_with_pt.test_client()
|
||||
|
||||
|
||||
def test_portuguese_fallback_pb_to_pt(client_with_pt):
|
||||
response = client_with_pt.post("/translate", data={
|
||||
"q": "Hello",
|
||||
"source": "en",
|
||||
"target": "pb",
|
||||
"format": "text"
|
||||
})
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_portuguese_fallback_pt_to_pb(client_with_pb):
|
||||
response = client_with_pb.post("/translate", data={
|
||||
"q": "Hello",
|
||||
"source": "en",
|
||||
"target": "pt",
|
||||
"format": "text"
|
||||
})
|
||||
|
||||
assert response.status_code == 200
|
||||
Loading…
x
Reference in New Issue
Block a user