Mercurial > p > roundup > code
comparison test/test_liveserver.py @ 6640:6ac3667706be
Test german translation of start page.
Issue 2551199 wants to remove translationService from templating.py.
I wanted to get some translation test in place that went through
templating. AFAICT, translation test are done through the i18n
interface and not via the web interface.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 26 Apr 2022 17:22:33 -0400 |
| parents | 198875530c04 |
| children | 53c9b62494e6 |
comparison
equal
deleted
inserted
replaced
| 6639:9f3fe52b7a2e | 6640:6ac3667706be |
|---|---|
| 104 f = requests.get(self.url_base()) | 104 f = requests.get(self.url_base()) |
| 105 self.assertEqual(f.status_code, 200) | 105 self.assertEqual(f.status_code, 200) |
| 106 self.assertTrue(b'Roundup' in f.content) | 106 self.assertTrue(b'Roundup' in f.content) |
| 107 self.assertTrue(b'Creator' in f.content) | 107 self.assertTrue(b'Creator' in f.content) |
| 108 | 108 |
| 109 def test_start_in_german(self): | |
| 110 """ simple test that verifies that the server can serve a start page | |
| 111 and translate text to german. Use page title and remeber login | |
| 112 checkbox label. | |
| 113 """ | |
| 114 f = requests.get(self.url_base() + "?@language=de") | |
| 115 self.assertEqual(f.status_code, 200) | |
| 116 print(f.content) | |
| 117 self.assertTrue(b'Roundup' in f.content) | |
| 118 self.assertTrue(b'Aufgabenliste' in f.content) | |
| 119 self.assertTrue(b'dauerhaft anmelden?' in f.content) | |
| 109 | 120 |
| 110 def test_rest_invalid_method_collection(self): | 121 def test_rest_invalid_method_collection(self): |
| 111 # use basic auth for rest endpoint | 122 # use basic auth for rest endpoint |
| 112 f = requests.put(self.url_base() + '/rest/data/user', | 123 f = requests.put(self.url_base() + '/rest/data/user', |
| 113 auth=('admin', 'sekrit'), | 124 auth=('admin', 'sekrit'), |
| 263 print(f.status_code) | 274 print(f.status_code) |
| 264 print(f.headers) | 275 print(f.headers) |
| 265 | 276 |
| 266 self.assertEqual(f.status_code, 404) | 277 self.assertEqual(f.status_code, 404) |
| 267 | 278 |
| 279 def test_rest_login_rate_limit(self): | |
| 280 """login rate limit applies to api endpoints. Only failure | |
| 281 logins count though. So log in 10 times in a row | |
| 282 to verify that valid username/passwords aren't limited. | |
| 283 """ | |
| 284 | |
| 285 for i in range(10): | |
| 286 # use basic auth for rest endpoint | |
| 287 | |
| 288 f = requests.options(self.url_base() + '/rest/data', | |
| 289 auth=('admin', 'sekrit'), | |
| 290 headers = {'content-type': ""} | |
| 291 ) | |
| 292 print(f.status_code) | |
| 293 print(f.headers) | |
| 294 | |
| 295 self.assertEqual(f.status_code, 204) | |
| 296 expected = { 'Access-Control-Allow-Origin': '*', | |
| 297 'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With, X-HTTP-Method-Override', | |
| 298 'Allow': 'OPTIONS, GET', | |
| 299 'Access-Control-Allow-Methods': 'HEAD, OPTIONS, GET, POST, PUT, DELETE, PATCH', | |
| 300 } | |
| 301 | |
| 302 for i in range(10): | |
| 303 # use basic auth for rest endpoint | |
| 304 | |
| 305 f = requests.options(self.url_base() + '/rest/data', | |
| 306 auth=('admin', 'ekrit'), | |
| 307 headers = {'content-type': ""} | |
| 308 ) | |
| 309 print(i, f.status_code) | |
| 310 print(f.headers) | |
| 311 print(f.text) | |
| 312 | |
| 313 self.assertEqual(f.status_code, 401) | |
| 314 | |
| 268 def test_ims(self): | 315 def test_ims(self): |
| 269 ''' retreive the user_utils.js file with old and new | 316 ''' retreive the user_utils.js file with old and new |
| 270 if-modified-since timestamps. | 317 if-modified-since timestamps. |
| 271 ''' | 318 ''' |
| 272 from datetime import datetime | 319 from datetime import datetime |
