diff test/db_test_base.py @ 5163:6ae426092d7d

Some patches from wking to make admin.py bypass checks like nuking a db. This is or use for testing only. Also some internal restructuring to use use new utility function _get_choice. Add a new test for admin install interface.
author John Rouillard <rouilj@ieee.org>
date Sat, 23 Jul 2016 17:08:44 -0400
parents e098536107ea
children e1e40674a0bc
line wrap: on
line diff
--- a/test/db_test_base.py	Sat Jul 23 15:22:06 2016 -0400
+++ b/test/db_test_base.py	Sat Jul 23 17:08:44 2016 -0400
@@ -2174,6 +2174,34 @@
         finally:
             roundup.admin.sys = sys
 
+
+    # test duplicate relative tracker home initialisation (issue2550757)
+    def testAdminDuplicateInitialisation(self):
+        import roundup.admin
+        output = []
+        def stderrwrite(s):
+            output.append(s)
+        roundup.admin.sys = MockNull ()
+        t = '_test_initialise'
+        try:
+            roundup.admin.sys.stderr.write = stderrwrite
+            tool = roundup.admin.AdminTool()
+            tool.force = True
+            args = (None, 'classic', 'anydbm',
+                    'MAIL_DOMAIN=%s' % config.MAIL_DOMAIN)
+            tool.do_install(t, args=args)
+            args = (None, 'mypasswd')
+            tool.do_initialise(t, args=args)
+            tool.do_initialise(t, args=args)
+            try:  # python >=2.7
+                self.assertNotIn(t, os.listdir(t))
+            except AttributeError:
+                self.assertFalse('db' in os.listdir(t))
+        finally:
+            roundup.admin.sys = sys
+            if os.path.exists(t):
+                shutil.rmtree(t)
+
     def testAddProperty(self):
         self.db.issue.create(title="spam", status='1')
         self.db.commit()

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