1- import os
2- import pytest
31import requests
42
53BASE_URL = "http://localhost:8080/json/assistant/translate"
64
75from utils import session
86
7+
98def print_response_on_error (response : requests .Response ):
109 if response .status_code >= 400 :
1110 print (f"\n [HTTP ERROR] { response .status_code } { response .reason } " )
1211 print (f"Response body:\n { response .text } \n " )
13- print (f"Response body:\n { response .text } \n " )
12+ print (f"Response body:\n { response .json ()} \n " )
13+
1414
1515def test_translate_minimal (session ):
1616 params = {
@@ -21,6 +21,20 @@ def test_translate_minimal(session):
2121 print_response_on_error (response )
2222 assert response .status_code == 200
2323 assert response .text .strip () # should contain translation
24+ assert response .json ().strip () # should be JSON
25+
26+
27+ def test_translate_umlauts (session ):
28+ params = {
29+ "text" : "flowers bloom in spring." ,
30+ "language" : "de" ,
31+ }
32+ response = session .post (BASE_URL , params = params )
33+ print_response_on_error (response )
34+ assert response .status_code == 200
35+ assert response .text .strip () # should contain translation
36+ assert "ü" in response .json ()
37+
2438
2539def test_translate_with_characteristic (session ):
2640 params = {
@@ -33,6 +47,7 @@ def test_translate_with_characteristic(session):
3347 assert response .status_code == 200
3448 assert response .text .strip ()
3549
50+
3651def test_translate_with_simplified (session ):
3752 params = {
3853 "text" : "Hallo Welt!" ,
@@ -44,6 +59,7 @@ def test_translate_with_simplified(session):
4459 assert response .status_code == 200
4560 assert response .text .strip ()
4661
62+
4763def test_translate_conflicting_simplified_and_characteristic (session ):
4864 params = {
4965 "text" : "Hallo Welt!" ,
@@ -55,6 +71,7 @@ def test_translate_conflicting_simplified_and_characteristic(session):
5571 print_response_on_error (response )
5672 assert response .status_code == 400 # BadRequest
5773
74+
5875def test_translate_missing_parameters (session ):
5976 params = {
6077 "language" : "en"
0 commit comments