def setUp(self): self.submin_env = tempfile.mkdtemp(prefix='submin-unittest') self.conf_dir = os.path.join(self.submin_env, 'conf') os.mkdir(self.conf_dir) self.authz_file = os.path.join(self.submin_env, 'conf', 'authz') mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() options.set_value('vcs_plugins', 'svn') options.set_value('svn_dir', 'svn') options.set_value('trac_dir', 'trac') options.set_value('svn_authz_file', 'conf/authz') options.set_value('enabled_trac', 'no') options.set_value('http_vhost', 'localhost') options.set_value('base_url_submin', '/submin') self.svn_dir = str(options.env_path('svn_dir')) self.trac_dir = str(options.env_path('trac_dir')) os.mkdir(self.svn_dir) os.mkdir(self.trac_dir) # now make some repositories self.repositories = [ {'name': 'foo', 'status': 'ok', 'vcs': 'svn'}, {'name': 'invalidperm', 'status': 'permission denied', 'vcs': 'svn'}, {'name': 'invalidperm2', 'status': 'permission denied', 'vcs': 'svn'}, {'name': 'example', 'status': 'ok', 'vcs': 'svn'}, {'name': 'subdirs', 'status': 'ok', 'vcs': 'svn'}, ] self.has_invalidperm = False self.has_invalidperm2 = False
def setUp(self): self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest')) conf_dir = self.submin_env + 'conf' os.mkdir(conf_dir) mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() self.sa = MagicMock() self.sa.env = self.submin_env self.saved_stdout, sys.stdout = sys.stdout, StringIO()
def setUp(self): self.submin_env = Path(tempfile.mkdtemp(prefix='submin-unittest')) conf_dir = self.submin_env + 'conf' os.mkdir(conf_dir) mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() options.set_value('svn_authz_file', conf_dir + 'authz') # needed for export options.set_value('svn_dir', self.submin_env + 'svn') # needed for export options.set_value('git_dir', self.submin_env + 'git') options.set_value('vcs_plugins', 'svn, git')
def setUp(self): self.submin_env = tempfile.mkdtemp(prefix='submin-unittest') self.conf_dir = os.path.join(self.submin_env, 'conf') os.mkdir(self.conf_dir) self.authz_file = os.path.join(self.submin_env, 'conf', 'authz') mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() options.set_value('vcs_plugins', 'svn') options.set_value('svn_dir', 'svn') options.set_value('trac_dir', 'trac') options.set_value('svn_authz_file', 'conf/authz') options.set_value('enabled_trac', 'no') options.set_value('http_vhost', 'localhost') options.set_value('base_url_submin', '/submin') self.svn_dir = str(options.env_path('svn_dir')) self.trac_dir = str(options.env_path('trac_dir')) os.mkdir(self.svn_dir) os.mkdir(self.trac_dir) # now make some repositories self.repositories = [ { 'name': 'foo', 'status': 'ok', 'vcs': 'svn' }, { 'name': 'invalidperm', 'status': 'permission denied', 'vcs': 'svn' }, { 'name': 'invalidperm2', 'status': 'permission denied', 'vcs': 'svn' }, { 'name': 'example', 'status': 'ok', 'vcs': 'svn' }, { 'name': 'subdirs', 'status': 'ok', 'vcs': 'svn' }, ] self.has_invalidperm = False self.has_invalidperm2 = False
def handler(self, req, path): localvars = {} localvars['uptodated'] = True localvars['base_url'] = options.url_path('base_url_submin') if database_isuptodate(): localvars['alreadyuptodate'] = True else: database_evolve() localvars['alreadyuptodate'] = False formatted = evaluate('database_upgrade.html', localvars) return Response(formatted)
def settings_defaults(self, filename): # write the bootstrap settings file submin_settings = ''' import os storage = "sql" sqlite_path = os.path.join(os.path.dirname(__file__), "submin.db") ''' dirname = os.path.dirname(filename) mkdirs(dirname) file(filename, 'w').write(submin_settings) # after writing the bootstrap file, we setup all models self.sa.ensure_storage() from submin.models import storage storage.database_evolve() # And now we can use the models from submin.models import options import platform http_base = '' default_options = { 'base_url_submin': http_base + '/submin', 'base_url_svn': http_base + '/svn', 'base_url_git': http_base + '/git', 'base_url_trac': http_base + '/trac', 'http_vhost': platform.node(), 'auth_type': 'sql', 'svn_dir': 'svn', 'git_dir': 'git', 'trac_dir': 'trac', 'dir_bin': 'static/bin', 'enabled_trac': 'no', 'enabled_external': 'no', 'external_server': 'ldaps://example.net', 'external_base_dn': 'DC=example,DC=net', 'external_group_dn': 'CN=SVN,OU=SVN,DC=example,DC=net', 'external_user': '******', 'external_passwd': 'secret', 'external_upn_suffix': 'example.net', 'session_salt': self.session_salt(), 'env_path': '/bin:/usr/bin:/usr/local/bin:/opt/local/bin', 'vcs_plugins': 'git,svn', } for (key, value) in default_options.iteritems(): options.set_value(key, value) self.generate_cgi()
def setUp(self): self.submin_env = Path(tempfile.mkdtemp(prefix="submin-unittest")) conf_dir = self.submin_env + "conf" svn_dir = self.submin_env + "svn" os.mkdir(conf_dir) os.mkdir(svn_dir) mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() options.set_value("svn_authz_file", conf_dir + "authz") # needed for export options.set_value("svn_dir", svn_dir) # needed for export options.set_value("git_dir", self.submin_env + "git") options.set_value("vcs_plugins", "svn, git") self.tmp_dirs = [] user.add("test", email="[email protected]", password="******") self.u = user.User("test")
def setUp(self): self.submin_env = tempfile.mkdtemp(prefix='submin-unittest') self.conf_dir = os.path.join(self.submin_env, 'conf') os.mkdir(self.conf_dir) mock_settings.base_dir = self.submin_env storage.open(mock_settings) storage.database_evolve() options.set_value('vcs_plugins', 'svn') options.set_value('svn_dir', 'svn') options.set_value('trac_dir', 'trac') options.set_value('svn_authz_file', 'conf/authz') options.set_value('enabled_trac', 'yes') self.svn_dir = str(options.env_path('svn_dir')) self.trac_dir = str(options.env_path('trac_dir')) os.mkdir(self.svn_dir) os.mkdir(self.trac_dir)
def settings_defaults(self, filename): # write the bootstrap settings file submin_settings = ''' import os storage = "sql" sqlite_path = os.path.join(os.path.dirname(__file__), "submin.db") ''' dirname = os.path.dirname(filename) mkdirs(dirname) file(filename, 'w').write(submin_settings) # after writing the bootstrap file, we setup all models self.sa.ensure_storage() from submin.models import storage storage.database_evolve() # And now we can use the models from submin.models import options import platform http_base = '' default_options = { 'base_url_submin': http_base + '/submin', 'base_url_svn': http_base + '/svn', 'base_url_git': http_base + '/git', 'base_url_trac': http_base + '/trac', 'http_vhost': platform.node(), 'auth_type': 'sql', 'svn_dir': 'svn', 'git_dir': 'git', 'trac_dir': 'trac', 'dir_bin': 'static/bin', 'enabled_trac': 'no', 'session_salt': self.session_salt(), 'env_path': '/bin:/usr/bin:/usr/local/bin:/opt/local/bin', 'vcs_plugins': 'git,svn', } for (key, value) in default_options.iteritems(): options.set_value(key, value) self.generate_cgi()
def setUp(self): storage.open(mock_settings) storage.database_evolve()
def subcmd_database(self, argv): from submin.models import storage new_version = storage.database_evolve(verbose=True)