def test_git_install_skip_existing_nongit(path=None): with swallow_logs(new_level=logging.WARNING) as log: dist_dir = GitDistribution(name="git", packages=[ GitRepo(path=path, remotes={ "origin": { "url": "doesnt-matter", "contains": True } }) ]) dist_dir.install_packages() assert "not a Git repository; skipping" in log.out with swallow_logs(new_level=logging.WARNING) as log: dist_dir = GitDistribution(name="git", packages=[ GitRepo(path=op.join(path, "foo"), remotes={ "origin": { "url": "doesnt-matter", "contains": True } }) ]) dist_dir.install_packages() assert "not a directory; skipping" in log.out
def test_git_install_no_remote(): dist = GitDistribution(name="git", packages=[GitRepo(path="/tmp/shouldnt/matter")]) with swallow_logs(new_level=logging.WARNING) as log: dist.initiate() dist.install_packages() assert "No remote known" in log.out
def test_git_install_skip_different_git(git_repo): with swallow_logs(new_level=logging.WARNING) as log: dist_dir = GitDistribution( name="git", packages=[ GitRepo(path=git_repo, root_hexsha="definitely doesn't match", remotes={ "origin": { "url": "doesnt-matter", "contains": True } }) ]) dist_dir.install_packages() assert "doesn't match expected hexsha; skipping" in log.out
def test_spec_round_trip(): # FIXME: This should also test GitDistribution's, but RepromanProvenance # can't currently load those (gh-222). spec = EnvironmentSpec(distributions=[ DebianDistribution( name="debian", apt_sources=[ APTSource(name="apt_Debian_stable_main_0", component="main", archive="stable", architecture="amd64", codename="stretch", origin="Debian", label="Debian", site="ftp.us.debian.org", archive_uri="http://ftp.us.debian.org/debian", date="2018-03-10 10:21:19+00:00") ], packages=[ DEBPackage(name="debpackage"), DEBPackage(name="libc-bin", upstream_name=None, version="2.24-11+deb9u3", architecture="amd64", source_name="glibc", source_version=None, size="779468", md5="3b9aaa83b5253895b8e13509659662e4", sha1=None, sha256="aaa", versions={ "2.24-11+deb9u1": ["apt_Debian_stable_foo"], "2.24-11+deb9u3": ["apt_Debian_stable_bar", "apt__now__0"] }, install_date="2018-03-12 10:55:13+00:00", files=["/usr/bin/zdump"]) ], version="9.4"), CondaDistribution( name="conda", path="/path/to/miniconda3", conda_version="4.4.10", python_version="3.6.3.final.0", platform="linux-64", environments=[ CondaEnvironment( name="root", path="/path/to/miniconda3", packages=[ CondaPackage(name="condapkg"), CondaPackage(version="36.5.0", build="py36he42e2e1_0", name="setuptools", md5="cb1383539629db998105faf7e91e2bc7", url="https://somewhere") ], channels=[ CondaChannel(name="defaults", url="https://somewhere") ]), CondaEnvironment(name="other", path="/path/to/miniconda3", packages=[CondaPackage(name="condapkg2")]) ]), GitDistribution(name="git", packages=[GitRepo(path="/path/to/repo")]), SVNDistribution(name="svn", packages=[SVNRepo(path="/path/to/repo")]), VenvDistribution( name="venv0", path="/usr/bin/virtualenv", venv_version="15.1.0", environments=[ VenvEnvironment(path="venv-reproman", python_version="3.5.3", packages=[ VenvPackage( version="3.12", name="PyYAML", location="/path/to/venv/site-packages", local=True) ]) ]), VenvDistribution(name="venv1") ]) output = io.StringIO() RepromanProvenance.write(output, spec) loaded = RepromanProvenance(output.getvalue()).get_environment() assert spec == loaded