changeset 8675:3afc6bff84bb

db_manage: drop special DbManage mode for tests There is no need for a special mode - just use force_ask to answer yes to "destroy old database".
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 10 Oct 2020 20:04:51 +0200
parents 30aac95e7fd5
children 6fbbbd9a627a
files kallithea/lib/db_manage.py kallithea/tests/fixture.py
diffstat 2 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/db_manage.py	Sat Oct 10 19:59:54 2020 +0200
+++ b/kallithea/lib/db_manage.py	Sat Oct 10 20:04:51 2020 +0200
@@ -49,9 +49,8 @@
 
 
 class DbManage(object):
-    def __init__(self, dbconf, root, tests=False, SESSION=None, cli_args=None):
+    def __init__(self, dbconf, root, SESSION=None, cli_args=None):
         self.dbname = dbconf.split('/')[-1]
-        self.tests = tests
         self.root = root
         self.dburi = dbconf
         self.cli_args = cli_args or {}
@@ -87,10 +86,9 @@
         else:
             log.info("The existing database %r will be destroyed and a new one created." % database)
 
-        if not self.tests:
-            if not self._ask_ok('Are you sure to destroy old database? [y/n]'):
-                print('Nothing done.')
-                sys.exit(0)
+        if not self._ask_ok('Are you sure to destroy old database? [y/n]'):
+            print('Nothing done.')
+            sys.exit(0)
 
         if reuse_database:
             Base.metadata.drop_all()
@@ -197,7 +195,7 @@
 
         if _path is not None:
             path = _path
-        elif not self.tests and not test_repo_path:
+        elif not test_repo_path:
             path = input(
                  'Enter a valid absolute path to store repositories. '
                  'All repositories in that path will be added automatically:'
--- a/kallithea/tests/fixture.py	Sat Oct 10 19:59:54 2020 +0200
+++ b/kallithea/tests/fixture.py	Sat Oct 10 20:04:51 2020 +0200
@@ -366,8 +366,8 @@
         os.makedirs(repos_test_path)
 
     dbmanage = DbManage(dbconf=dbconf, root=config['here'],
-                        tests=True,
                         cli_args={
+                            'force_ask': True,
                             'username': TEST_USER_ADMIN_LOGIN,
                             'password': TEST_USER_ADMIN_PASS,
                             'email': TEST_USER_ADMIN_EMAIL,