Mercurial > p > roundup > code
comparison test/test_liveserver.py @ 8241:741ea8a86012
fix: issue2551374. Error handling for filter expressions.
Errors in filter expressions are now reported. The UI needs some work
but even the current code is helpful when debugging filter
expressions.
mlink_expr:
defines/raises ExpressionError(error string template,
context=dict())
raises ExpressionError when it detects errors when popping arguments
off stack
raises ExpressionError when more than one element left on the stack
before returning
also ruff fix to group boolean expression with parens
back_anydbm.py, rdbms_common.py:
catches ExpressionError, augments context with class and
attribute being searched. raises the exception
for both link and multilink relations
client.py
catches ExpressionError returning a basic error page. The page is a
dead end. There are no links or anything for the user to move
forward. The user has to go back, possibly refresh the page (because
the submit button may be disalbled) re-enter the query and try
again.
This needs to be improved.
test_liveserver.py
test the error page generated by client.py
db_test_base
unit tests for filter with too few arguments, too many arguments,
check all repr and str formats.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 30 Dec 2024 20:22:55 -0500 |
| parents | 9404d56d830f |
| children | 393dfc750d8b |
comparison
equal
deleted
inserted
replaced
| 8240:1189c742e4b3 | 8241:741ea8a86012 |
|---|---|
| 349 self.assertIn('List of issues\n - Test1', f.text) | 349 self.assertIn('List of issues\n - Test1', f.text) |
| 350 # We should have no rows, so verify the static part | 350 # We should have no rows, so verify the static part |
| 351 # of the footer is missing. | 351 # of the footer is missing. |
| 352 self.assertNotIn('out of', f.text) | 352 self.assertNotIn('out of', f.text) |
| 353 | 353 |
| 354 def test_broken_query(self): | |
| 355 # query link item | |
| 356 current_user_query = ( | |
| 357 "@columns=title,id,activity,status,assignedto&" | |
| 358 "@sort=activity&@group=priority&@filter=creator&" | |
| 359 "@pagesize=50&@startwith=0&creator=-2&" | |
| 360 "@dispname=Test1") | |
| 361 | |
| 362 session, _response = self.create_login_session() | |
| 363 f = session.get(self.url_base()+'/issue?' + current_user_query) | |
| 364 | |
| 365 # verify the query has run by looking for the query name | |
| 366 # print(f.text) | |
| 367 self.assertIn('Error when searching issue by creator using: ' | |
| 368 '[-2]. The operator -2 (not) at position 1 has ' | |
| 369 'too few arguments.', | |
| 370 f.text) | |
| 371 | |
| 372 def test_broken_multiink_query(self): | |
| 373 # query multilink item | |
| 374 current_user_query = ( | |
| 375 "@columns=title,id,activity,status,assignedto" | |
| 376 "&keyword=-3&@sort=activity&@group=priority" | |
| 377 "&@pagesize=50&@startwith=0&@template=index|search" | |
| 378 "&@action=search") | |
| 379 session, _response = self.create_login_session() | |
| 380 f = session.get(self.url_base()+'/issue?' + current_user_query) | |
| 381 | |
| 382 # verify the query has run by looking for the query name | |
| 383 print(f.text) | |
| 384 self.assertIn('Error when searching issue by keyword using: ' | |
| 385 '[-3]. The operator -3 (and) at position 1 has ' | |
| 386 'too few arguments.', | |
| 387 f.text) | |
| 388 | |
| 354 def test_start_page(self): | 389 def test_start_page(self): |
| 355 """ simple test that verifies that the server can serve a start page. | 390 """ simple test that verifies that the server can serve a start page. |
| 356 """ | 391 """ |
| 357 f = requests.get(self.url_base()) | 392 f = requests.get(self.url_base()) |
| 358 self.assertEqual(f.status_code, 200) | 393 self.assertEqual(f.status_code, 200) |
