@@ -21,6 +21,7 @@ class FastAPIEncryptedErrorsCase(CommonAPILog):
2121 def setUpClass (cls ):
2222 super ().setUpClass ()
2323 cls .fastapi_demo_app = cls .env .ref ("fastapi.fastapi_endpoint_demo" )
24+ cls .fastapi_demo_app .root_path += "/test"
2425 cls .fastapi_demo_app ._handle_registry_sync ()
2526 cls .fastapi_demo_app .write ({"log_requests" : True })
2627 lang = (
@@ -57,27 +58,27 @@ def test_no_log_if_disabled(self):
5758 self .fastapi_demo_app .write ({"log_requests" : False })
5859
5960 with self .log_capturer () as capturer :
60- response = self .url_open ("/fastapi_demo/demo" , timeout = 200 )
61+ response = self .url_open ("/fastapi_demo/test/ demo" , timeout = 200 )
6162 self .assertEqual (response .status_code , status .HTTP_200_OK )
6263
6364 self .assertFalse (capturer .records )
6465
6566 def test_log_simple (self ):
6667 with self .log_capturer () as capturer :
67- response = self .url_open ("/fastapi_demo/demo" , timeout = 200 )
68+ response = self .url_open ("/fastapi_demo/test/ demo" , timeout = 200 )
6869 self .assertEqual (response .status_code , status .HTTP_200_OK )
6970
7071 self .assertEqual (len (capturer .records ), 1 )
7172 log = capturer .records [0 ]
72- self .assertTrue (log .request_url .endswith ("/fastapi_demo/demo" ))
73+ self .assertTrue (log .request_url .endswith ("/fastapi_demo/test/ demo" ))
7374 self .assertEqual (log .request_method , "GET" )
7475 self .assertEqual (log .response_status_code , 200 )
7576 self .assertTrue (log .time > 0 )
7677
7778 def test_log_exception (self ):
7879 with self .log_capturer () as capturer :
7980 route = (
80- "/fastapi_demo/demo/exception?"
81+ "/fastapi_demo/test/ demo/exception?"
8182 f"exception_type={ DemoExceptionType .user_error .value } "
8283 "&error_message=User Error"
8384 )
@@ -86,7 +87,7 @@ def test_log_exception(self):
8687
8788 self .assertEqual (len (capturer .records ), 1 )
8889 log = capturer .records [0 ]
89- self .assertIn ("/fastapi_demo/demo/exception" , log .request_url )
90+ self .assertIn ("/fastapi_demo/test/ demo/exception" , log .request_url )
9091 self .assertEqual (log .request_method , "GET" )
9192 self .assertEqual (log .response_status_code , 400 )
9293 self .assertTrue (log .time > 0 )
@@ -97,7 +98,7 @@ def test_log_exception(self):
9798 def test_log_bare_exception (self ):
9899 with self .log_capturer () as capturer :
99100 route = (
100- "/fastapi_demo/demo/exception?"
101+ "/fastapi_demo/test/ demo/exception?"
101102 f"exception_type={ DemoExceptionType .bare_exception .value } "
102103 "&error_message=Internal Server Error"
103104 )
@@ -108,7 +109,7 @@ def test_log_bare_exception(self):
108109
109110 self .assertEqual (len (capturer .records ), 1 )
110111 log = capturer .records [0 ]
111- self .assertIn ("/fastapi_demo/demo/exception" , log .request_url )
112+ self .assertIn ("/fastapi_demo/test/ demo/exception" , log .request_url )
112113 self .assertEqual (log .request_method , "GET" )
113114 self .assertEqual (log .response_status_code , 500 )
114115 self .assertTrue (log .time > 0 )
@@ -119,7 +120,7 @@ def test_log_bare_exception(self):
119120 def test_log_retrying_post (self ):
120121 with self .log_capturer () as capturer :
121122 nbr_retries = 2
122- route = f"/fastapi_demo/demo/retrying?nbr_retries={ nbr_retries } "
123+ route = f"/fastapi_demo/test/ demo/retrying?nbr_retries={ nbr_retries } "
123124 response = self .url_open (
124125 route , timeout = 20 , files = {"file" : ("test.txt" , b"test" )}
125126 )
@@ -130,7 +131,7 @@ def test_log_retrying_post(self):
130131
131132 self .assertEqual (len (capturer .records ), 3 )
132133 for log in capturer .records [0 :- 1 ]:
133- self .assertIn ("/fastapi_demo/demo/retrying" , log .request_url )
134+ self .assertIn ("/fastapi_demo/test/ demo/retrying" , log .request_url )
134135 self .assertEqual (log .request_method , "POST" )
135136 self .assertEqual (log .response_status_code , 500 )
136137 self .assertTrue (log .time > 0 )
@@ -142,7 +143,7 @@ def test_log_retrying_post(self):
142143 )
143144
144145 log = capturer .records [- 1 ]
145- self .assertIn ("/fastapi_demo/demo/retrying" , log .request_url )
146+ self .assertIn ("/fastapi_demo/test/ demo/retrying" , log .request_url )
146147 self .assertEqual (log .request_method , "POST" )
147148 self .assertEqual (log .response_status_code , 200 )
148149 self .assertTrue (log .time > 0 )
0 commit comments