def test_get_url_https(self): url, args = get_url_and_args(self.ctx.blueprint.id, { 'source': 'https://google.com', 'install_arguments': '--pre' }) self.assertEqual(url, 'https://google.com') self.assertEqual(args, '--pre')
def test_get_url_and_args_local_plugin(self): mock_plugin = { 'source': MOCK_PLUGIN, 'install_arguments': '-r requirements' } url, args = get_url_and_args(self.ctx.blueprint.id, mock_plugin) self.assertEqual( url, '{0}/{1}/{2}.{3}'.format(MANAGER_FILE_SERVER_BLUEPRINTS_ROOT_URL, PLUGINS_DIR, MOCK_PLUGIN, ZIP_SUFFIX))
def test_extract_url(self): plugin_source = '{0}/{1}/{2}.{3}'.format( MANAGER_FILE_SERVER_BLUEPRINTS_ROOT_URL, PLUGINS_DIR, MOCK_PLUGIN, TAR_SUFFIX) plugin = {'name': MOCK_PLUGIN, 'source': plugin_source} url, args = get_url_and_args(self.ctx.blueprint.id, plugin) source_plugin_path = os.path.join(dirname(__file__), MOCK_PLUGIN) extracted_plugin_path = extract_plugin_dir(url) self.assertTrue( PluginInstallerTestCase.are_dir_trees_equal( source_plugin_path, extracted_plugin_path))
def test_get_url_and_args_local_plugin(self): mock_plugin = { 'source': MOCK_PLUGIN, 'install_arguments': '-r requirements' } url, args = get_url_and_args(self.ctx.blueprint.id, mock_plugin) self.assertEqual(url, '{0}/{1}/{2}.{3}' .format( MANAGER_FILE_SERVER_BLUEPRINTS_ROOT_URL, PLUGINS_DIR, MOCK_PLUGIN, ZIP_SUFFIX))
def test_extract_url(self): plugin_source = '{0}/{1}/{2}.{3}'.format( MANAGER_FILE_SERVER_BLUEPRINTS_ROOT_URL, PLUGINS_DIR, MOCK_PLUGIN, TAR_SUFFIX) plugin = { 'name': MOCK_PLUGIN, 'source': plugin_source } url, args = get_url_and_args(self.ctx.blueprint.id, plugin) source_plugin_path = os.path.join(dirname(__file__), MOCK_PLUGIN) extracted_plugin_path = extract_plugin_dir(url) self.assertTrue(PluginInstallerTestCase.are_dir_trees_equal( source_plugin_path, extracted_plugin_path))
def test_get_url_and_args_http_no_args(self): url, args = get_url_and_args(self.ctx.blueprint.id, {'source': 'http://google.com'}) self.assertEqual(url, 'http://google.com') self.assertEqual(args, '')
def test_get_url_https(self): url, args = get_url_and_args(self.ctx.blueprint.id, {'source': 'https://google.com', 'install_arguments': '--pre'}) self.assertEqual(url, 'https://google.com') self.assertEqual(args, '--pre')