def test_build_in_virtualenv(self): from infi.execute import ExecutionError from urllib import urlretrieve with self.temporary_directory_context(): try: self.execute_assert_success("virtualenv virtualenv-python") except ExecutionError: raise SkipTest("Skipping because virtualenv does not work") virtualenv_dir = path.abspath( path.join(curdir, 'virtualenv-python')) bin_dir = path.join( virtualenv_dir, 'Scripts' if assertions.is_windows() else 'bin') python = path.join(bin_dir, 'python') with utils.chdir(PROJECT_ROOT): self.execute_assert_success( "{python} setup.py develop".format(python=python)) with patch.object(sys, "executable", new=python + '.exe' if assertions.is_windows() else python): with patch.object(sys, "real_prefix", new=sys.prefix, create=True): self.test_build_after_init()
def test_local_behind_origin__no_fetch(self): from os import curdir from os.path import abspath, basename from infi.projector.helper.utils import chdir with self.temporary_directory_context(): self.projector("repository init a.b.c none short long") self.projector("devenv build --no-scripts") origin = abspath(curdir) with self.temporary_directory_context(): self.projector("repository clone {}".format(origin)) with chdir(basename(origin)): self.projector("devenv build --no-scripts") with chdir(origin): repository = LocalRepository(curdir) repository.checkout("master") repository.commit("empty commit", allowEmpty=True) self.projector("version release 1.2.3 --no-fetch --no-upload --no-push-changes")
def temporary_directory_context(self): from tempfile import mkdtemp from shutil import rmtree from infi.projector.helper.utils import chdir tempdir = mkdtemp() with chdir(tempdir): yield tempdir rmtree(tempdir, ignore_errors=True)
def test_local_behind_origin(self): from os import curdir from os.path import abspath, basename from infi.projector.helper.utils import chdir if is_windows: raise SkipTest("skipping test on windows") with self.temporary_directory_context(): self.projector("repository init a.b.c none short long") self.projector("devenv build --no-scripts --no-readline") origin = abspath(curdir) with self.temporary_directory_context(): self.projector("repository clone {}".format(origin)) with chdir(basename(origin)): self.projector("devenv build --no-scripts --no-readline") with chdir(origin): repository = LocalRepository(curdir) repository.checkout("master") repository.commit("empty commit", allowEmpty=True) with self.assertRaises(SystemExit): self.projector("version release 1.2.3 --no-upload --no-push-changes")
def test_clone(self): from os import curdir, name from os.path import abspath if is_windows: raise SkipTest("skipping test on windows") with self.temporary_directory_context(): self.projector("repository init --mkdir a.b.c none short long") origin = abspath(path.join(curdir, 'a.b.c')) with self.temporary_directory_context(): self.assert_is_empty() self.projector("repository clone {}".format(origin)) with utils.chdir('a.b.c'): self.assert_project_checked_out()
def test_local_behind_origin(self): from os import curdir from os.path import abspath, basename from infi.projector.helper.utils import chdir if is_windows: raise SkipTest("skipping test on windows") with self.temporary_directory_context(): self.projector("repository init a.b.c none short long") self.projector("devenv build --no-scripts --no-readline") origin = abspath(curdir) with self.temporary_directory_context(): self.projector("repository clone {}".format(origin)) with chdir(basename(origin)): self.projector("devenv build --no-scripts --no-readline") with chdir(origin): repository = LocalRepository(curdir) repository.checkout("master") repository.commit("empty commit", allowEmpty=True) with self.assertRaises(SystemExit): self.projector( "version release 1.2.3 --no-upload --no-push-changes" )
def test_build_in_virtualenv(self): from infi.execute import ExecutionError with self.temporary_directory_context(): try: self.execute_assert_success("virtualenv --distribute virtualenv-python") except ExecutionError, error: raise SkipTest("Skipping because virtualenv does not work") virtualenv_dir = path.abspath(path.join(curdir, 'virtualenv-python')) bin_dir = path.join(virtualenv_dir, 'Scripts' if assertions.is_windows() else 'bin') python = path.join(bin_dir, 'python') with utils.chdir(PROJECT_ROOT): self.execute_assert_success("{python} setup.py develop".format(python=python)) with patch.object(sys, "executable", new=python+'.exe' if assertions.is_windows() else python): with patch.object(sys, "real_prefix", new=True, create=True): self.test_build_after_init()
def test_release_with_push(self): from infi.projector.helper.utils import chdir from os import path, curdir from gitpy import LocalRepository with self.mock_build_and_upload_distributions(): with self.temporary_directory_context() as origin_location: self.projector("repository init a.b.c none short long") self.projector("devenv build --no-scripts") self.projector("version release minor --no-fetch --pypi-servers= --no-push-changes") git_config = path.join(".git", "config") LocalRepository(curdir)._executeGitCommandAssertSuccess("git config -f {} receive.denyCurrentBranch ignore".format(git_config)) with self.temporary_directory_context(): self.projector("repository clone {}".format(origin_location)) with chdir(path.basename(origin_location)): self.projector("devenv build --no-scripts") self.projector("version release minor --pypi-servers=")
def _create_subdir_if_necessary(self): from infi.projector.helper.utils import chdir from os.path import exists, isdir, sep from os import makedirs, name if not self.arguments.get('--mkdir'): yield return dirname = self.arguments.get('<project_name>') or self.arguments.get('<origin>') if name == 'nt': dirname = dirname.replace(sep, '/') dirname = (dirname if not dirname.endswith('.git') else dirname[0:-4]).split('/')[-1] if exists(dirname) and isdir(dirname): logger.debug("{} already exists".format(dirname)) raise SystemExit(1) makedirs(dirname) with chdir(dirname): yield
def test_build_in_virtualenv(self): from infi.execute import ExecutionError from urllib import urlretrieve with self.temporary_directory_context(): try: self.execute_assert_success("virtualenv virtualenv-python") except ExecutionError: raise SkipTest("Skipping because virtualenv does not work") virtualenv_dir = path.abspath(path.join(curdir, 'virtualenv-python')) bin_dir = path.join(virtualenv_dir, 'Scripts' if assertions.is_windows() else 'bin') python = path.join(bin_dir, 'python') urlretrieve("http://pypi01.infinidat.com/media/dists/ez_setup.py", "ez_setup.py") self.execute_assert_success("{python} ez_setup.py --download-base=http://pypi01.infinidat.com/media/dists/".format(python=python)) with utils.chdir(PROJECT_ROOT): self.execute_assert_success("{python} setup.py develop".format(python=python)) with patch.object(sys, "executable", new=python+'.exe' if assertions.is_windows() else python): with patch.object(sys, "real_prefix", new=True, create=True): self.test_build_after_init()
def test_init__mkdir(self): with self.temporary_directory_context(): self.assert_is_empty() self.projector("repository init --mkdir a.b.c none short long") with utils.chdir('a.b.c'): self.assert_project_checked_out()