Mercurial > p > roundup > code
diff test/test_admin.py @ 7395:312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
Running:
roundup-admin -i ... reindex issue:1-1000
will reindex the first 1000 issues while reporting any missing issues
in the range.
Also completion progress is reported when indexing a specific class.
Note this require a chnge that makes an invalid command like:
reindex issue23f
to error with no such class issue23f. It used to reindex
issue23 which I consider a bug.
Updates to man page admin_guide.py.
Tests added.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 24 May 2023 12:13:05 -0400 |
| parents | bd6523c84a95 |
| children | fc9daba984c0 |
line wrap: on
line diff
--- a/test/test_admin.py Wed May 24 11:48:04 2023 -0400 +++ b/test/test_admin.py Wed May 24 12:13:05 2023 -0400 @@ -1035,6 +1035,86 @@ # ----- AdminTool.my_input = orig_input + def testReindex(self): + ''' Note the tests will fail if you run this under pdb. + the context managers capture the pdb prompts and this screws + up the stdout strings with (pdb) prefixed to the line. + ''' + self.install_init() + + # create an issue + self.admin=AdminTool() + sys.argv=['main', '-i', self.dirname, 'create', 'issue', + 'title="foo bar"', 'assignedto=admin' ] + ret = self.admin.main() + + # reindex everything + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex'] + ret = self.admin.main() + out = out.getvalue().strip() + print(len(out)) + print(repr(out)) + # make sure priority is being reindexed + self.assertIn('Reindex priority 40%', out) + + + # reindex whole class + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex', 'issue'] + ret = self.admin.main() + + out = out.getvalue().strip() + print(len(out)) + print(repr(out)) + self.assertEqual(out, + 'Reindex issue 0% \rReindex issue 100% \rReindex issue done') + self.assertEqual(len(out), 170) + + # reindex one item + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex', 'issue1'] + ret = self.admin.main() + + out = out.getvalue().strip() + print(len(out)) + print(repr(out)) + # no output when reindexing just one item + self.assertEqual(out, '') + + # reindex range + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex', 'issue:1-4'] + ret = self.admin.main() + + out = out.getvalue().strip() + print(repr(out)) + self.assertIn('no such item "issue3"', out) + + # reindex bad class + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex', 'issue1-4'] + ret = self.admin.main() + + out = out.getvalue().strip() + print(repr(out)) + self.assertIn('Error: no such class "issue1-4"', out) + + # reindex bad item + self.admin=AdminTool() + with captured_output() as (out, err): + sys.argv=['main', '-i', self.dirname, 'reindex', 'issue14'] + ret = self.admin.main() + + out = out.getvalue().strip() + print(repr(out)) + self.assertIn('Error: no such item "issue14"', out) + def disabletestHelpInitopts(self): ''' Note the tests will fail if you run this under pdb.
