Mercurial > p > roundup > code
comparison test/test_admin.py @ 7547:c8c4514f4c3e
issue685275 - show retired/unretire commands
For roundup-admin, add pragma show_retired [no, only, both] to control
showing retired items in list and table commands:
no - do not show retired
only - only show retired
both - show retired and unretired (active) items
Also sort results of Class::getnodeids() in back_anydbm.py. Anydbm
Class::list() expicitly sorts the returned values and a test depends
on the order of the returned items.
I can't find any docs that say Class::list() sorts and there is no
explicit sort in the rdbms_common.py implementation. It looks like
the natural order returned in the rdbms case for these methods is
sorted.
However the test fails for the anydbm case if I don't sort the results
of back_anydbm.py:Class::getnodeids() to match
back_anydbm.py:Class::list().
This also fixes a spelling error in comment.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 14 Jul 2023 20:34:30 -0400 |
| parents | 534f8bdb8f94 |
| children | 793f4b63c538 |
comparison
equal
deleted
inserted
replaced
| 7546:534f8bdb8f94 | 7547:c8c4514f4c3e |
|---|---|
| 1610 out = out.getvalue().strip() | 1610 out = out.getvalue().strip() |
| 1611 print(out) | 1611 print(out) |
| 1612 expected="1: admin\n 2: anonymous\n 3: user1" | 1612 expected="1: admin\n 2: anonymous\n 3: user1" |
| 1613 self.assertEqual(out, expected) | 1613 self.assertEqual(out, expected) |
| 1614 | 1614 |
| 1615 # test show_retired pragma three cases: | |
| 1616 # no - no retired items | |
| 1617 # only - only retired items | |
| 1618 # both - all items | |
| 1619 | |
| 1620 # verify that user4 only is listed | |
| 1621 self.admin=AdminTool() | |
| 1622 with captured_output() as (out, err): | |
| 1623 sys.argv=['main', '-i', self.dirname, '-P', | |
| 1624 'show_retired=only', 'list', 'user'] | |
| 1625 ret = self.admin.main() | |
| 1626 out = out.getvalue().strip() | |
| 1627 print(out) | |
| 1628 expected="4: user1" | |
| 1629 self.assertEqual(out, expected) | |
| 1630 | |
| 1631 # verify that all users are shown | |
| 1632 self.admin=AdminTool() | |
| 1633 with captured_output() as (out, err): | |
| 1634 sys.argv=['main', '-i', self.dirname, '-P', | |
| 1635 'show_retired=both', 'list', 'user'] | |
| 1636 ret = self.admin.main() | |
| 1637 out = out.getvalue().strip() | |
| 1638 print(out) | |
| 1639 expected="1: admin\n 2: anonymous\n 3: user1\n 4: user1" | |
| 1640 self.assertEqual(out, expected) | |
| 1641 | |
| 1642 | |
| 1643 # verify that active users | |
| 1644 self.admin=AdminTool() | |
| 1645 with captured_output() as (out, err): | |
| 1646 sys.argv=['main', '-i', self.dirname, '-P', | |
| 1647 'show_retired=no', 'list', 'user'] | |
| 1648 ret = self.admin.main() | |
| 1649 out = out.getvalue().strip() | |
| 1650 print(out) | |
| 1651 expected="1: admin\n 2: anonymous\n 3: user1" | |
| 1652 self.assertEqual(out, expected) | |
| 1615 | 1653 |
| 1616 | 1654 |
| 1617 def testTable(self): | 1655 def testTable(self): |
| 1618 ''' Note the tests will fail if you run this under pdb. | 1656 ''' Note the tests will fail if you run this under pdb. |
| 1619 the context managers capture the pdb prompts and this screws | 1657 the context managers capture the pdb prompts and this screws |
