Esempio n. 1
0
 def test_kontext_conf_remap(self):
     create_dirs()
     conf_data = get_conf()
     conf_data['kontextConfAliases'] = {'tagsets.xml': 'tag.xml'}
     conf = deploy.Configuration(conf_data)
     self.assertTrue('tag.xml' in conf.kontext_conf_files)
     self.assertFalse('tagsets.xml' in conf.kontext_conf_files)
Esempio n. 2
0
 def test_update_working_conf(self):
     create_dirs()
     conf = deploy.Configuration(get_conf())
     dp = deploy.Deployer(conf)
     dp.update_working_conf()
     conf_copy_path = os.path.join(WORKING_DIR, 'conf/config.xml')
     self.assertTrue(os.path.isfile(conf_copy_path))
     with open(conf_copy_path, 'rb') as fr:
         self.assertEqual(KONTEXT_CONF_DATA['config.xml'], fr.read())
Esempio n. 3
0
 def test_create_archive(self):
     create_dirs()
     conf = deploy.Configuration(get_conf())
     dp = deploy.Deployer(conf)
     date_items = (2001, 9, 20, 12, 30, 41)
     arch_path = dp.create_archive(datetime(*date_items))
     exp_arch_path = os.path.join(ARCHIVE_DIR,
                                  '-'.join('%02d' % x for x in date_items))
     self.assertTrue(os.path.isdir(exp_arch_path))
     self.assertEqual(exp_arch_path, arch_path)
Esempio n. 4
0
 def test_ok_config(self):
     create_dirs()
     conf = deploy.Configuration(get_conf())
     self.assertEqual(APP_DIR, conf.app_dir)
     self.assertEqual(WORKING_DIR, conf.working_dir)
     self.assertEqual(ARCHIVE_DIR, conf.archive_dir)
     self.assertEqual(APP_CONF_DIR, conf.app_config_dir)
     self.assertEqual(GIT_REPO_URL, conf.git_url)
     self.assertEqual(GIT_BRANCH, conf.git_branch)
     self.assertEqual(GIT_REMOTE, conf.git_remote)
Esempio n. 5
0
 def test_remove_current_deployment(self):
     create_dirs()
     os.makedirs(os.path.join(APP_DIR, 'foo/bar'))
     with open(os.path.join(APP_DIR, 'foo/bar/test.txt'), 'wb') as fw:
         fw.write('lorem ipsum dolor sit amet...')
     with open(os.path.join(APP_DIR, 'package.json'), 'wb') as fw:
         fw.write('{}')
     conf = deploy.Configuration(get_conf())
     dp = deploy.Deployer(conf)
     dp.remove_current_deployment()
     self.assertEqual(0, len(os.listdir(APP_DIR)))
Esempio n. 6
0
 def test_copy_app_to_archive(self):
     create_dirs()
     conf = deploy.Configuration(get_conf())
     dp = deploy.Deployer(conf)
     date_items = (2001, 9, 20, 12, 30, 41)
     arch_path = os.path.join(ARCHIVE_DIR,
                              '-'.join('%02d' % x for x in date_items))
     os.makedirs(arch_path)
     dp.copy_app_to_archive(arch_path)
     for item in deploy.FILES:
         self.assertTrue(os.path.exists(os.path.join(arch_path, item)))
Esempio n. 7
0
 def test_copy_configuration(self):
     create_dirs()
     conf = deploy.Configuration(get_conf())
     dp = deploy.Deployer(conf)
     date_items = (2001, 9, 20, 12, 30, 41)
     arch_path = dp.create_archive(datetime(*date_items))
     dp.copy_configuration(arch_path)
     exp_arch_path = os.path.join(ARCHIVE_DIR,
                                  '-'.join('%02d' % x for x in date_items))
     for item in os.listdir(exp_arch_path):
         self.assertTrue(item in deploy.Configuration.KONTEXT_CONF_FILES)
Esempio n. 8
0
 def test_forbidden_path(self):
     create_dirs()
     rev_conf = dict((v, k) for k, v in get_conf().items())
     tmp = [APP_DIR, WORKING_DIR, ARCHIVE_DIR, APP_CONF_DIR]
     root_items = ['/%s' % x for x in os.listdir('/')]
     for path in tmp:
         for root_item in root_items:
             conf = get_conf()
             conf[rev_conf[path]] = root_item
             with self.assertRaises(deploy.ConfigError):
                 deploy.Configuration(conf, skip_remote_checks=True)
Esempio n. 9
0
 def test_relative_path(self):
     create_dirs()
     rev_conf = dict((v, k) for k, v in get_conf().items())
     tmp = {
         APP_DIR: 'deployment/app',
         WORKING_DIR: 'deployment/working',
         ARCHIVE_DIR: 'deployment/archive',
         APP_CONF_DIR: 'deployment/app_conf'
     }
     for path in tmp.keys():
         conf = get_conf()
         conf[rev_conf[path]] = tmp[path]
         with self.assertRaises(deploy.ConfigError):
             deploy.Configuration(conf, skip_remote_checks=True)
Esempio n. 10
0
 def test_empty_config(self):
     with self.assertRaises(TypeError):
         deploy.Configuration(None)
     with self.assertRaises(KeyError):
         deploy.Configuration({})
Esempio n. 11
0
 def test_invalid_git_url(self):
     create_dirs()
     conf_data = get_conf()
     conf_data['gitUrl'] = 'http://foo.something'
     with self.assertRaises(deploy.ConfigError):
         deploy.Configuration(conf_data)
Esempio n. 12
0
 def test_non_existing_workdir(self):
     for item in [APP_DIR, WORKING_DIR, ARCHIVE_DIR, APP_CONF_DIR]:
         create_dirs()
         rmfile(item)
         with self.assertRaises(deploy.ConfigError):
             deploy.Configuration(get_conf(), skip_remote_checks=True)