Mercurial > p > roundup > code
comparison test/test_admin.py @ 6188:32ebffbae49a
Setup basic genconfig and updateconfig tests.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 07 Jun 2020 17:13:28 -0400 |
| parents | 81babf5a4494 |
| children | 7458211ca6f3 |
comparison
equal
deleted
inserted
replaced
| 6187:cc66cf905147 | 6188:32ebffbae49a |
|---|---|
| 273 print(out) | 273 print(out) |
| 274 # out can be "['2', '1']" or "['1', '2']" | 274 # out can be "['2', '1']" or "['1', '2']" |
| 275 # so eval to real list so Equal can do a list compare | 275 # so eval to real list so Equal can do a list compare |
| 276 self.assertEqual(sorted(eval(out)), ['1', '2']) | 276 self.assertEqual(sorted(eval(out)), ['1', '2']) |
| 277 | 277 |
| 278 def testGenconfigUpdate(self): | |
| 279 ''' Note the tests will fail if you run this under pdb. | |
| 280 the context managers capture the pdb prompts and this screws | |
| 281 up the stdout strings with (pdb) prefixed to the line. | |
| 282 ''' | |
| 283 import sys | |
| 284 | |
| 285 self.admin=AdminTool() | |
| 286 self.install_init() | |
| 287 | |
| 288 with captured_output() as (out, err): | |
| 289 sys.argv=['main', '-i', '_test_admin', 'genconfig'] | |
| 290 ret = self.admin.main() | |
| 291 | |
| 292 out = out.getvalue().strip() | |
| 293 print(out) | |
| 294 expected = "Not enough arguments supplied" | |
| 295 self.assertTrue(expected in out) | |
| 296 | |
| 297 # Reopen the db closed by previous call | |
| 298 self.admin=AdminTool() | |
| 299 | |
| 300 with captured_output() as (out, err): | |
| 301 sys.argv=['main', '-i', '_test_admin', 'genconfig', "foo"] | |
| 302 ret = self.admin.main() | |
| 303 | |
| 304 out = out.getvalue().strip() | |
| 305 print(out) | |
| 306 # FIXME get better successful test later. | |
| 307 expected = "" | |
| 308 self.assertTrue(expected in out) | |
| 309 | |
| 310 # Reopen the db closed by previous call | |
| 311 self.admin=AdminTool() | |
| 312 | |
| 313 with captured_output() as (out, err): | |
| 314 sys.argv=['main', '-i', '_test_admin', 'update', "foo2"] | |
| 315 ret = self.admin.main() | |
| 316 | |
| 317 out = out.getvalue().strip() | |
| 318 print(out) | |
| 319 # FIXME get better successful test later. | |
| 320 expected = "" | |
| 321 self.assertTrue(expected in out) | |
| 322 | |
| 278 def testCliParse(self): | 323 def testCliParse(self): |
| 279 ''' Note the tests will fail if you run this under pdb. | 324 ''' Note the tests will fail if you run this under pdb. |
| 280 the context managers capture the pdb prompts and this screws | 325 the context managers capture the pdb prompts and this screws |
| 281 up the stdout strings with (pdb) prefixed to the line. | 326 up the stdout strings with (pdb) prefixed to the line. |
| 282 ''' | 327 ''' |
| 330 out = out.getvalue().strip() | 375 out = out.getvalue().strip() |
| 331 print(out) | 376 print(out) |
| 332 expected=('Unknown command "xyzzy" ' | 377 expected=('Unknown command "xyzzy" ' |
| 333 '("help commands" for a list)') | 378 '("help commands" for a list)') |
| 334 self.assertEqual(expected, out) | 379 self.assertEqual(expected, out) |
| 335 | |
| 336 | 380 |
| 337 # Reopen the db closed by previous call | 381 # Reopen the db closed by previous call |
| 338 self.admin=AdminTool() | 382 self.admin=AdminTool() |
| 339 # test for keyword=value check | 383 # test for keyword=value check |
| 340 with captured_output() as (out, err): | 384 with captured_output() as (out, err): |
