Mercurial > p > roundup > code
comparison test/rest_common.py @ 5842:9c6617857032
Support use of duplicate rest filters keys. So URL's like:
issues?title=foo&title=bar
will find titles with the words foo and bar but not just foo and not
just bar. Url like:
issues?status=open,resolved&status=closed
will find any issue with open, closed or resolved status.
Original code would only use the last title or status filter erasing
the earlier one.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 10 Jul 2019 20:49:41 -0400 |
| parents | bcb894bc9740 |
| children | 04deafac71ab |
comparison
equal
deleted
inserted
replaced
| 5841:f2804ec3bd06 | 5842:9c6617857032 |
|---|---|
| 456 title='foo1', | 456 title='foo1', |
| 457 status=self.db.status.lookup('open'), | 457 status=self.db.status.lookup('open'), |
| 458 priority=self.db.priority.lookup('normal') | 458 priority=self.db.priority.lookup('normal') |
| 459 ) | 459 ) |
| 460 issue_open_norm = self.db.issue.create( | 460 issue_open_norm = self.db.issue.create( |
| 461 title='foo2', | 461 title='foo2 normal', |
| 462 status=self.db.status.lookup('open'), | 462 status=self.db.status.lookup('open'), |
| 463 priority=self.db.priority.lookup('normal') | 463 priority=self.db.priority.lookup('normal') |
| 464 ) | 464 ) |
| 465 issue_closed_norm = self.db.issue.create( | 465 issue_closed_norm = self.db.issue.create( |
| 466 title='foo3', | 466 title='foo3 closed normal', |
| 467 status=self.db.status.lookup('closed'), | 467 status=self.db.status.lookup('closed'), |
| 468 priority=self.db.priority.lookup('normal') | 468 priority=self.db.priority.lookup('normal') |
| 469 ) | 469 ) |
| 470 issue_closed_crit = self.db.issue.create( | 470 issue_closed_crit = self.db.issue.create( |
| 471 title='foo4', | 471 title='foo4 closed', |
| 472 status=self.db.status.lookup('closed'), | 472 status=self.db.status.lookup('closed'), |
| 473 priority=self.db.priority.lookup('critical') | 473 priority=self.db.priority.lookup('critical') |
| 474 ) | 474 ) |
| 475 issue_open_crit = self.db.issue.create( | 475 issue_open_crit = self.db.issue.create( |
| 476 title='foo5', | 476 title='foo5', |
| 526 results['data']['collection']) | 526 results['data']['collection']) |
| 527 self.assertNotIn(get_obj(base_path, issue_open_crit), | 527 self.assertNotIn(get_obj(base_path, issue_open_crit), |
| 528 results['data']['collection']) | 528 results['data']['collection']) |
| 529 self.assertNotIn(get_obj(base_path, issue_open_norm), | 529 self.assertNotIn(get_obj(base_path, issue_open_norm), |
| 530 results['data']['collection']) | 530 results['data']['collection']) |
| 531 | |
| 532 # Retrieve all issue status=closed and priority=normal,critical | |
| 533 # using duplicate priority key's. | |
| 534 form = cgi.FieldStorage() | |
| 535 form.list = [ | |
| 536 cgi.MiniFieldStorage('status', 'closed'), | |
| 537 cgi.MiniFieldStorage('priority', 'normal'), | |
| 538 cgi.MiniFieldStorage('priority', 'critical') | |
| 539 ] | |
| 540 results = self.server.get_collection('issue', form) | |
| 541 self.assertEqual(self.dummy_client.response_code, 200) | |
| 542 self.assertIn(get_obj(base_path, issue_closed_crit), | |
| 543 results['data']['collection']) | |
| 544 self.assertIn(get_obj(base_path, issue_closed_norm), | |
| 545 results['data']['collection']) | |
| 546 self.assertNotIn(get_obj(base_path, issue_open_crit), | |
| 547 results['data']['collection']) | |
| 548 self.assertNotIn(get_obj(base_path, issue_open_norm), | |
| 549 results['data']['collection']) | |
| 550 | |
| 551 # Retrieve all issues with title containing | |
| 552 # closed, normal and 3 using duplicate title filterkeys | |
| 553 form = cgi.FieldStorage() | |
| 554 form.list = [ | |
| 555 cgi.MiniFieldStorage('title', 'closed'), | |
| 556 cgi.MiniFieldStorage('title', 'normal'), | |
| 557 cgi.MiniFieldStorage('title', '3') | |
| 558 ] | |
| 559 results = self.server.get_collection('issue', form) | |
| 560 self.assertEqual(self.dummy_client.response_code, 200) | |
| 561 self.assertNotIn(get_obj(base_path, issue_closed_crit), | |
| 562 results['data']['collection']) | |
| 563 self.assertIn(get_obj(base_path, issue_closed_norm), | |
| 564 results['data']['collection']) | |
| 565 self.assertNotIn(get_obj(base_path, issue_open_crit), | |
| 566 results['data']['collection']) | |
| 567 self.assertNotIn(get_obj(base_path, issue_open_norm), | |
| 568 results['data']['collection']) | |
| 569 self.assertEqual(len(results['data']['collection']), 1) | |
| 570 | |
| 571 # Retrieve all issues (no hits) with title containing | |
| 572 # closed, normal and foo3 in this order using title filter | |
| 573 form = cgi.FieldStorage() | |
| 574 form.list = [ | |
| 575 cgi.MiniFieldStorage('title', 'closed normal foo3') | |
| 576 ] | |
| 577 results = self.server.get_collection('issue', form) | |
| 578 self.assertEqual(self.dummy_client.response_code, 200) | |
| 579 self.assertNotIn(get_obj(base_path, issue_closed_crit), | |
| 580 results['data']['collection']) | |
| 581 self.assertNotIn(get_obj(base_path, issue_closed_norm), | |
| 582 results['data']['collection']) | |
| 583 self.assertNotIn(get_obj(base_path, issue_open_crit), | |
| 584 results['data']['collection']) | |
| 585 self.assertNotIn(get_obj(base_path, issue_open_norm), | |
| 586 results['data']['collection']) | |
| 587 self.assertEqual(len(results['data']['collection']), 0) | |
| 588 | |
| 589 # Retrieve all issues with title containing | |
| 590 # foo3, closed and normal in this order using title filter | |
| 591 form = cgi.FieldStorage() | |
| 592 form.list = [ | |
| 593 cgi.MiniFieldStorage('title', 'foo3 closed normal') | |
| 594 ] | |
| 595 results = self.server.get_collection('issue', form) | |
| 596 self.assertEqual(self.dummy_client.response_code, 200) | |
| 597 self.assertNotIn(get_obj(base_path, issue_closed_crit), | |
| 598 results['data']['collection']) | |
| 599 self.assertIn(get_obj(base_path, issue_closed_norm), | |
| 600 results['data']['collection']) | |
| 601 self.assertNotIn(get_obj(base_path, issue_open_crit), | |
| 602 results['data']['collection']) | |
| 603 self.assertNotIn(get_obj(base_path, issue_open_norm), | |
| 604 results['data']['collection']) | |
| 605 self.assertEqual(len(results['data']['collection']), 1) | |
| 606 | |
| 607 # Retrieve all issues with word closed in title | |
| 608 form = cgi.FieldStorage() | |
| 609 form.list = [ | |
| 610 cgi.MiniFieldStorage('title', 'closed'), | |
| 611 ] | |
| 612 results = self.server.get_collection('issue', form) | |
| 613 self.assertEqual(self.dummy_client.response_code, 200) | |
| 614 self.assertIn(get_obj(base_path, issue_closed_crit), | |
| 615 results['data']['collection']) | |
| 616 self.assertIn(get_obj(base_path, issue_closed_norm), | |
| 617 results['data']['collection']) | |
| 618 self.assertNotIn(get_obj(base_path, issue_open_crit), | |
| 619 results['data']['collection']) | |
| 620 self.assertNotIn(get_obj(base_path, issue_open_norm), | |
| 621 results['data']['collection']) | |
| 622 self.assertEqual(len(results['data']['collection']), 2) | |
| 531 | 623 |
| 532 def testPagination(self): | 624 def testPagination(self): |
| 533 """ | 625 """ |
| 534 Test pagination. page_size is required and is an integer | 626 Test pagination. page_size is required and is an integer |
| 535 starting at 1. page_index is optional and is an integer | 627 starting at 1. page_index is optional and is an integer |
