Mercurial > p > roundup > code
comparison test/test_admin.py @ 7883:23b7669b2f48
test: fix path issues posix vs windows in admin functions.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 18 Apr 2024 19:53:50 -0400 |
| parents | fe77e4325084 |
| children | c12377fb4144 |
comparison
equal
deleted
inserted
replaced
| 7882:77c109725a7e | 7883:23b7669b2f48 |
|---|---|
| 367 print(ret) | 367 print(ret) |
| 368 self.assertTrue(ret == 0) | 368 self.assertTrue(ret == 0) |
| 369 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) | 369 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) |
| 370 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) | 370 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) |
| 371 | 371 |
| 372 self.admin=AdminTool() | 372 nopath= '/tmp/noSuchDirectory/nodir' |
| 373 with captured_output() as (out, err): | 373 norealpath = os.path.realpath(nopath + "/..") |
| 374 sys.argv=['main', '-i', '/tmp/noSuchDirectory/nodir', 'install', 'classic', self.backend] | 374 self.admin=AdminTool() |
| 375 with captured_output() as (out, err): | |
| 376 sys.argv=['main', '-i', nopath, 'install', 'classic', self.backend] | |
| 375 ret = self.admin.main() | 377 ret = self.admin.main() |
| 376 | 378 |
| 377 out = out.getvalue().strip() | 379 out = out.getvalue().strip() |
| 378 print(ret) | 380 print(ret) |
| 379 print(out) | 381 print(out) |
| 380 self.assertEqual(ret, 1) | 382 self.assertEqual(ret, 1) |
| 381 self.assertIn('Error: Instance home parent directory ' | 383 self.assertIn('Error: Instance home parent directory ' |
| 382 '"/tmp/noSuchDirectory" does not exist', out) | 384 '"%s" does not exist' % norealpath, out) |
| 383 | 385 |
| 384 def testInitWithConfig_ini(self): | 386 def testInitWithConfig_ini(self): |
| 385 from roundup.configuration import CoreConfig | 387 from roundup.configuration import CoreConfig |
| 386 self.admin=AdminTool() | 388 self.admin=AdminTool() |
| 387 sys.argv=['main', '-i', self.dirname, 'install', 'classic', self.backend] | 389 sys.argv=['main', '-i', self.dirname, 'install', 'classic', self.backend] |
| 408 print(ret) | 410 print(ret) |
| 409 self.assertTrue(ret == 0) | 411 self.assertTrue(ret == 0) |
| 410 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) | 412 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) |
| 411 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) | 413 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) |
| 412 config=CoreConfig(self.dirname) | 414 config=CoreConfig(self.dirname) |
| 413 self.assertEqual(config['MAIL_DEBUG'], self.dirname + "/SendMail.LOG") | 415 self.assertEqual(config['MAIL_DEBUG'], |
| 416 os.path.normpath(self.dirname + "/SendMail.LOG")) | |
| 414 | 417 |
| 415 def testList(self): | 418 def testList(self): |
| 416 ''' Note the tests will fail if you run this under pdb. | 419 ''' Note the tests will fail if you run this under pdb. |
| 417 the context managers capture the pdb prompts and this screws | 420 the context managers capture the pdb prompts and this screws |
| 418 up the stdout strings with (pdb) prefixed to the line. | 421 up the stdout strings with (pdb) prefixed to the line. |
