def _build_test_index(workdir): pkgs = api.build(os.path.join(metadata_dir, "_index_hotfix_pkgs"), croot=workdir) for pkg in pkgs: conda_package_handling.api.transmute(pkg, '.conda') api.update_index(workdir) with open(os.path.join(workdir, subdir, 'repodata.json')) as f: original_metadata = json.load(f) pkg_list = original_metadata['packages'] assert "track_features_test-1.0-0.tar.bz2" in pkg_list assert pkg_list["track_features_test-1.0-0.tar.bz2"][ "track_features"] == "dummy" assert "hotfix_depends_test-1.0-dummy_0.tar.bz2" in pkg_list assert pkg_list["hotfix_depends_test-1.0-dummy_0.tar.bz2"][ "features"] == "dummy" assert "zlib" in pkg_list["hotfix_depends_test-1.0-dummy_0.tar.bz2"][ "depends"] assert "revoke_test-1.0-0.tar.bz2" in pkg_list assert "zlib" in pkg_list["revoke_test-1.0-0.tar.bz2"]["depends"] assert "package_has_been_revoked" not in pkg_list[ "revoke_test-1.0-0.tar.bz2"]["depends"] assert "remove_test-1.0-0.tar.bz2" in pkg_list
def test_channeldata_picks_up_all_versions_of_run_exports(): pkg_dir = os.path.join(os.path.dirname(__file__), 'index_data', 'packages') api.update_index(pkg_dir) with open(os.path.join(pkg_dir, 'channeldata.json')) as f: repodata = json.load(f) run_exports = repodata['packages']['run_exports_versions']['run_exports'] assert len(run_exports) == 2 assert "1.0" in run_exports assert "2.0" in run_exports
def test_patch_instructions_with_missing_subdir(testing_workdir): os.makedirs('linux-64') os.makedirs('zos-z') api.update_index('.') # we use conda-forge's patch instructions because they don't have zos-z data, and that triggers an error pkg = "conda-forge-repodata-patches" url = "https://anaconda.org/conda-forge/{0}/20180828/download/noarch/{0}-20180828-0.tar.bz2".format(pkg) patch_instructions = download(url, os.path.join(os.getcwd(), "patches.tar.bz2")) api.update_index('.', patch_generator=patch_instructions)
def test_patch_instructions_with_missing_subdir(testing_workdir): os.makedirs('linux-64') os.makedirs('zos-z') api.update_index('.') # we use conda-forge's patch instructions because they don't have zos-z data, and that triggers an error pkg = "conda-forge-repodata-patches" url = "https://anaconda.org/conda-forge/{0}/20180828/download/noarch/{0}-20180828-0.tar.bz2".format(pkg) patch_instructions = download(url, os.path.join(os.getcwd(), "patches.tar.bz2")) api.update_index('.', patch_generator=patch_instructions)
def test_index_of_removed_pkg(testing_metadata): out_files = api.build(testing_metadata) for f in out_files: os.remove(f) api.update_index(testing_metadata.config.croot) with open( os.path.join(testing_metadata.config.croot, subdir, 'repodata.json')) as f: repodata = json.load(f) assert not repodata['packages']
def test_index_of_removed_pkg(testing_metadata): out_files = api.build(testing_metadata) for f in out_files: os.remove(f) api.update_index(testing_metadata.config.croot) with open(os.path.join(testing_metadata.config.croot, subdir, 'repodata.json')) as f: repodata = json.load(f) assert not repodata['packages'] with open(os.path.join(testing_metadata.config.croot, subdir, 'repodata_from_packages.json')) as f: repodata = json.load(f) assert not repodata['packages']
def test_current_index_version_keys_keep_older_packages(testing_workdir): pkg_dir = os.path.join(os.path.dirname(__file__), 'index_data', 'packages') # pass no version file api.update_index(pkg_dir) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) # only the newest version is kept assert len(repodata['packages']) == 1 assert list(repodata['packages'].values())[0]['version'] == "2.0" # pass version file api.update_index(pkg_dir, current_index_versions=os.path.join( pkg_dir, 'versions.yml')) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) assert len(repodata['packages']) == 2 # pass dict that is equivalent to version file api.update_index(pkg_dir, current_index_versions={'dummy-package': ["1.0"]}) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) assert list(repodata['packages'].values())[0]['version'] == "1.0"
def _build_test_index(workdir): pkgs = api.build(os.path.join(metadata_dir, "_index_hotfix_pkgs"), croot=workdir) for pkg in pkgs: conda_package_handling.api.transmute(pkg, '.conda') api.update_index(workdir) with open(os.path.join(workdir, subdir, 'repodata.json')) as f: original_metadata = json.load(f) pkg_list = original_metadata['packages'] assert "track_features_test-1.0-0.tar.bz2" in pkg_list assert pkg_list["track_features_test-1.0-0.tar.bz2"]["track_features"] == "dummy" assert "hotfix_depends_test-1.0-dummy_0.tar.bz2" in pkg_list assert pkg_list["hotfix_depends_test-1.0-dummy_0.tar.bz2"]["features"] == "dummy" assert "zlib" in pkg_list["hotfix_depends_test-1.0-dummy_0.tar.bz2"]["depends"] assert "revoke_test-1.0-0.tar.bz2" in pkg_list assert "zlib" in pkg_list["revoke_test-1.0-0.tar.bz2"]["depends"] assert "package_has_been_revoked" not in pkg_list["revoke_test-1.0-0.tar.bz2"]["depends"] assert "remove_test-1.0-0.tar.bz2" in pkg_list
def test_current_index_version_keys_keep_older_packages(testing_workdir): pkg_dir = os.path.join(os.path.dirname(__file__), 'index_data', 'packages') # pass no version file api.update_index(pkg_dir) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) # only the newest version is kept assert len(repodata['packages']) == 1 assert list(repodata['packages'].values())[0]['version'] == "2.0" # pass version file api.update_index(pkg_dir, current_index_versions=os.path.join(pkg_dir, 'versions.yml')) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) assert len(repodata['packages']) == 2 # pass dict that is equivalent to version file api.update_index(pkg_dir, current_index_versions={'dummy-package': ["1.0"]}) with open(os.path.join(pkg_dir, 'osx-64', 'current_repodata.json')) as f: repodata = json.load(f) assert list(repodata['packages'].values())[0]['version'] == "1.0"
def test_index_invalid_packages(): pkg_dir = os.path.join(os.path.dirname(__file__), 'index_data', 'corrupt') api.update_index(pkg_dir) with open(os.path.join(pkg_dir, 'channeldata.json')) as f: repodata = json.load(f) assert len(repodata['packages']) == 0