Changeset - 3afc6bff84bb
[Not reviewed]
default
0 2 0
Mads Kiilerich - 5 years ago 2020-10-10 20:04:51
mads@kiilerich.com
Grafted from: d7bd8c2dc13d
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".
2 files changed with 6 insertions and 8 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/db_manage.py
Show inline comments
 
@@ -49,9 +49,8 @@ log = logging.getLogger(__name__)
 

	
 

	
 
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 @@ class DbManage(object):
 
        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 @@ class DbManage(object):
 

	
 
        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:'
kallithea/tests/fixture.py
Show inline comments
 
@@ -366,8 +366,8 @@ def create_test_env(repos_test_path, con
 
        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,
0 comments (0 inline, 0 general)