def test_get_installed_version(self): github_plugin = GithubPlugin('org/repo#my-version') src_fixture = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resources', 'plugin_sha') dest = github_plugin.get_plugin_folder() shutil.copytree(src_fixture, dest) actual = github_plugin.get_installed_version() shutil.rmtree(dest) self.assertEqual('my-version', actual)
def test_extract(self): github_plugin = GithubPlugin('org/test-pgo-plugin#2d54eddde33061be9b329efae0cfb9bd58842655') src = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resources', 'test-pgo-plugin-2d54eddde33061be9b329efae0cfb9bd58842655.zip') zip_dest = github_plugin.get_local_destination() shutil.copyfile(src, zip_dest) github_plugin.extract() plugin_folder = github_plugin.get_plugin_folder() os.path.isdir(plugin_folder) sub_folder = os.path.join(plugin_folder, 'test-pgo-plugin') os.path.isdir(sub_folder) sha_file = os.path.join(github_plugin.get_plugin_folder(), '.sha') os.path.isfile(sha_file) with open(sha_file) as file: content = file.read().strip() self.assertEqual(content, '2d54eddde33061be9b329efae0cfb9bd58842655') shutil.rmtree(plugin_folder)
def test_is_already_installed_installed(self): github_plugin = GithubPlugin('org/repo#sha') plugin_folder = github_plugin.get_plugin_folder() os.mkdir(plugin_folder) with open(os.path.join(plugin_folder, '.sha'), 'w') as file: file.write('sha') actual = github_plugin.is_already_installed() shutil.rmtree(plugin_folder) self.assertTrue(actual)
def test_get_plugin_folder(self): github_plugin = GithubPlugin('org/repo#sha') expected = os.path.join(PLUGIN_PATH, 'org_repo') actual = github_plugin.get_plugin_folder() self.assertEqual(actual, expected)