comparison test/test_config.py @ 6560:fdfe3b7387ea

Add test for config parse error by running AdminTool.
author John Rouillard <rouilj@ieee.org>
date Mon, 13 Dec 2021 22:18:15 -0500
parents 8687c096a945
children b1f1539c6a31
comparison
equal deleted inserted replaced
6559:178705fbeaa8 6560:fdfe3b7387ea
584 print(cm.exception) 584 print(cm.exception)
585 self.assertIn("'%' must be followed by '%' or '(', found: '% is invalid'", cm.exception.args[0]) 585 self.assertIn("'%' must be followed by '%' or '(', found: '% is invalid'", cm.exception.args[0])
586 self.assertIn("_test_instance/config.ini with section [main] at option admin_email", cm.exception.args[0]) 586 self.assertIn("_test_instance/config.ini with section [main] at option admin_email", cm.exception.args[0])
587 587
588 588
589 from roundup.admin import AdminTool
590 from .test_admin import captured_output
591
592 admin=AdminTool()
593 with captured_output() as (out, err):
594 sys.argv=['main', '-i', self.dirname, 'get', 'tile', 'issue1']
595 ret = admin.main()
596
597 expected_err = "Error in _test_instance/config.ini with section [main] at option admin_email: '%' must be followed by '%' or '(', found: '% is invalid'"
598
599 self.assertEqual(ret, 1)
600 out = out.getvalue().strip()
601 self.assertEqual(out, expected_err)
602
589 def testInvalidIndexerValue(self): 603 def testInvalidIndexerValue(self):
590 """ Mistype native indexer. Verify exception is 604 """ Mistype native indexer. Verify exception is
591 generated. 605 generated.
592 """ 606 """
593 607
607 # verify that args show up in string representaton 621 # verify that args show up in string representaton
608 string_rep = cm.exception.__str__() 622 string_rep = cm.exception.__str__()
609 print(string_rep) 623 print(string_rep)
610 self.assertIn("nati", string_rep) 624 self.assertIn("nati", string_rep)
611 self.assertIn("'whoosh'", string_rep) 625 self.assertIn("'whoosh'", string_rep)
612
613

Roundup Issue Tracker: http://roundup-tracker.org/