def test_tarball_match_specs(self): url = "https://conda.anaconda.org/conda-canary/linux-64/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert m(url) == "conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0" assert m("conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0") == "conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0" url = "https://conda.anaconda.org/conda-canary/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert m(url) == "*[url=%s]" % url pref1 = PackageRecord( channel=Channel(None), name="conda", version="4.3.21.post699+1dab973", build="py36h4a561cd_0", build_number=0, fn="conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2", url=url, ) pref2 = PackageRecord.from_objects(pref1, md5="1234") assert MatchSpec(url=url).match(pref1) assert MatchSpec(m(url)).match(pref1) assert MatchSpec(m(url)).match(pref1.dump()) assert not MatchSpec(url=url, md5="1234").match(pref1) assert not MatchSpec(url=url, md5="1234").match(pref1.dump()) assert MatchSpec(url=url, md5="1234").match(pref2) assert MatchSpec(url=url, md5="1234").get('md5') == "1234" url = "file:///var/folders/cp/7r2s_s593j7_cpdtxxsmct880000gp/T/edfc ñçêáôß/flask-0.10.1-py35_2.tar.bz2" assert m(url) == "*[url='%s']" % url
def test_tarball_match_specs(self): url = "https://conda.anaconda.org/conda-canary/linux-64/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert m( url ) == "conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0" assert m( "conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0" ) == "conda-canary/linux-64::conda==4.3.21.post699+1dab973=py36h4a561cd_0" url = "https://conda.anaconda.org/conda-canary/conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2" assert m(url) == "*[url=%s]" % url pref1 = PackageRecord( channel=Channel(None), name="conda", version="4.3.21.post699+1dab973", build="py36h4a561cd_0", build_number=0, fn="conda-4.3.21.post699+1dab973-py36h4a561cd_0.tar.bz2", url=url, ) pref2 = PackageRecord.from_objects(pref1, md5="1234") assert MatchSpec(url=url).match(pref1) assert MatchSpec(m(url)).match(pref1) assert MatchSpec(m(url)).match(pref1.dump()) assert not MatchSpec(url=url, md5="1234").match(pref1) assert not MatchSpec(url=url, md5="1234").match(pref1.dump()) assert MatchSpec(url=url, md5="1234").match(pref2) assert MatchSpec(url=url, md5="1234").get('md5') == "1234" url = "file:///var/folders/cp/7r2s_s593j7_cpdtxxsmct880000gp/T/edfc ñçêáôß/flask-0.10.1-py35_2.tar.bz2" assert m(url) == "*[url='%s']" % url
def test_general_graph_bfs_version(): a = PackageRecord(name="a", version="1", build="0", build_number=0, depends=["b", "c", "d"]) b = PackageRecord(name="b", version="1", build="0", build_number=0, depends=["e"]) c = PackageRecord(name="c", version="1", build="0", build_number=0, depends=["g=1"]) d = PackageRecord(name="d", version="1", build="0", build_number=0, depends=["f", "g=2"]) e = PackageRecord(name="e", version="1", build="0", build_number=0) f = PackageRecord(name="f", version="1", build="0", build_number=0) g1 = PackageRecord(name="g", version="1", build="0", build_number=0) g2 = PackageRecord(name="g", version="2", build="0", build_number=0) records = [a, b, c, d, e, f, g1, g2] graph = GeneralGraph(records) a_to_g1 = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("g=1")) assert a_to_g1 == [MatchSpec("a"), MatchSpec("c"), MatchSpec("g=1")] a_to_g2 = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("g=2")) assert a_to_g2 == [MatchSpec("a"), MatchSpec("d"), MatchSpec("g=2")]
def test_PackageCacheData_return_value_contract(): pc = PackageCacheData(context.pkgs_dirs[0]) single_pcrec = next(pc.iter_records(), None) if single_pcrec: get_result = pc.get(PackageRecord.from_objects(single_pcrec)) assert isinstance(get_result, PackageCacheRecord) query_result = pc.query('openssl') assert isinstance(query_result, tuple) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in query_result) query_all_result = PackageCacheData.query_all('openssl') assert isinstance(query_all_result, tuple) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in query_all_result) iter_records_result = pc.iter_records() assert isiterable(iter_records_result) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in iter_records_result) is_writable_result = pc.is_writable assert is_writable_result is True or is_writable_result is False first_writable_result = PackageCacheData.first_writable() assert isinstance(first_writable_result, PackageCacheData) reload_result = pc.reload() assert isinstance(reload_result, PackageCacheData)
def test_PackageCacheData_return_value_contract(): pc = PackageCacheData(context.pkgs_dirs[0]) single_pcrec = next(pc.iter_records(), None) if single_pcrec: get_result = pc.get(PackageRecord.from_objects(single_pcrec)) assert isinstance(get_result, PackageCacheRecord) query_result = pc.query('openssl') assert isinstance(query_result, tuple) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in query_result) query_all_result = PackageCacheData.query_all('openssl') assert isinstance(query_all_result, tuple) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in query_all_result) iter_records_result = pc.iter_records() assert isiterable(iter_records_result) assert all(isinstance(pcrec, PackageCacheRecord) for pcrec in iter_records_result) is_writable_result = pc.is_writable assert is_writable_result is True or is_writable_result is False first_writable_result = PackageCacheData.first_writable() assert isinstance(first_writable_result, PackageCacheData) reload_result = pc.reload() assert isinstance(reload_result, PackageCacheData)
def test_package_info(self): index_json_record = PackageRecord(build=0, build_number=0, name="test_foo", version=0, channel='defaults', subdir=context.subdir, fn='doesnt-matter', md5='0123456789') icondata = "icondata" package_metadata = PackageMetadata( package_metadata_version=1, noarch=Noarch(type="python", entry_points=["test:foo"]), ) paths = [PathData(_path="test/path/1", file_mode=FileMode.text, path_type=PathType.hardlink, prefix_placeholder="/opt/anaconda1anaconda2anaconda3", ), PathData(_path="test/path/2", no_link=True, path_type=PathType.hardlink), PathData(_path="test/path/3", path_type=PathType.softlink), PathData(_path="menu/test.json", path_type=PathType.hardlink)] paths_data = PathsData(paths_version=0, paths=paths) package_info = PackageInfo( extracted_package_dir='/some/path', channel=Channel('defaults'), repodata_record=index_json_record, url='https://some.com/place/file.tar.bz2', index_json_record=index_json_record, icondata=icondata, package_metadata=package_metadata, paths_data=paths_data, ) self.assertIsInstance(package_info.paths_data.paths[0], PathData) self.assertIsInstance(package_info.index_json_record, PackageRecord) self.assertIsInstance(package_info.package_metadata.noarch, Noarch) assert package_info.paths_data.paths[0].path == "test/path/1"
def to_package_record_from_subjson(entry, pkg, jsn_string): channel_url = entry["url"] info = json.loads(jsn_string) info["fn"] = pkg info["channel"] = to_conda_channel(entry["channel"], entry["platform"]) info["url"] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
def test_general_graph_bfs_simple(): a = PackageRecord(name="a", version="1", build="0", build_number=0, depends=["b", "c", "d"]) b = PackageRecord(name="b", version="1", build="0", build_number=0, depends=["e"]) c = PackageRecord(name="c", version="1", build="0", build_number=0) d = PackageRecord(name="d", version="1", build="0", build_number=0, depends=["f", "g"]) e = PackageRecord(name="e", version="1", build="0", build_number=0) f = PackageRecord(name="f", version="1", build="0", build_number=0) g = PackageRecord(name="g", version="1", build="0", build_number=0) records = [a, b, c, d, e, f, g] graph = GeneralGraph(records) a_to_c = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("c")) assert a_to_c == [MatchSpec("a"), MatchSpec("c")] a_to_f = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("f")) assert a_to_f == [MatchSpec("a"), MatchSpec("d"), MatchSpec("f")] a_to_a = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("a")) assert a_to_a == [MatchSpec("a")] a_to_not_exist = graph.breadth_first_search_by_name(MatchSpec("a"), MatchSpec("z")) assert a_to_not_exist is None backwards = graph.breadth_first_search_by_name(MatchSpec("d"), MatchSpec("a")) assert backwards is None
def to_package_record_from_subjson(subdir, pkg, jsn_string): channel = subdir.channel channel_url = subdir.url_w_credentials info = json.loads(jsn_string) info['fn'] = pkg info['channel'] = channel info['url'] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
def to_package_record_from_subjson(channel, pkg, jsn_string): channel = channel channel_url = channel.url(with_credentials=True) info = json.loads(jsn_string) info["fn"] = pkg info["channel"] = channel info["url"] = join_url(channel_url, pkg) package_record = PackageRecord(**info) return package_record
def DPkg(s, **kwargs): d = Dist(s) return PackageRecord(fn=d.to_filename(), name=d.name, version=d.version, build=d.build_string, build_number=int(d.build_string.rsplit('_', 1)[-1]), channel=d.channel, subdir=context.subdir, md5="012345789", **kwargs)
def test_index_record_timestamp(self): # regression test for #6096 ts_secs = 1507565728 ts_millis = ts_secs * 1000 rec = PackageRecord( name='test-package', version='1.2.3', build='2', build_number=2, timestamp=ts_secs ) assert rec.timestamp == ts_secs assert rec.dump()['timestamp'] == ts_millis ts_millis = 1507565728999 ts_secs = ts_millis / 1000 rec = PackageRecord( name='test-package', version='1.2.3', build='2', build_number=2, timestamp=ts_secs ) assert rec.timestamp == ts_secs assert rec.dump()['timestamp'] == ts_millis
def make_temp_channel(packages): package_reqs = [pkg.replace("-", "=") for pkg in packages] package_names = [pkg.split("-")[0] for pkg in packages] with make_temp_env(*package_reqs) as prefix: for package in packages: assert package_is_installed(prefix, package.replace("-", "=")) data = [ p for p in PrefixData(prefix).iter_records() if p["name"] in package_names ] run_command(Commands.REMOVE, prefix, *package_names) for package in packages: assert not package_is_installed(prefix, package.replace("-", "=")) repodata = {"info": {}, "packages": {}} tarfiles = {} for package_data in data: pkg_data = package_data fname = pkg_data["fn"] tarfiles[fname] = join(PackageCacheData.first_writable().pkgs_dir, fname) pkg_data = pkg_data.dump() for field in ("url", "channel", "schannel"): pkg_data.pop(field, None) repodata["packages"][fname] = PackageRecord(**pkg_data) with make_temp_env() as channel: subchan = join(channel, context.subdir) noarch_dir = join(channel, "noarch") channel = path_to_url(channel) os.makedirs(subchan) os.makedirs(noarch_dir) for fname, tar_old_path in tarfiles.items(): tar_new_path = join(subchan, fname) copyfile(tar_old_path, tar_new_path) with open(join(subchan, "repodata.json"), "w") as f: f.write(json.dumps(repodata, cls=EntityEncoder)) with open(join(noarch_dir, "repodata.json"), "w") as f: f.write(json.dumps({}, cls=EntityEncoder)) yield channel
def test_PrefixData_return_value_contract(): pd = PrefixData(context.conda_prefix) single_prefix_rec = next(pd.iter_records()) get_result = pd.get(PackageRecord.from_objects(single_prefix_rec)) assert isinstance(get_result, PrefixRecord) query_result = pd.query('openssl') assert isinstance(query_result, tuple) assert all(isinstance(prefix_rec, PrefixRecord) for prefix_rec in query_result) iter_records_result = pd.iter_records() assert isiterable(iter_records_result) assert all(isinstance(prefix_rec, PrefixRecord) for prefix_rec in iter_records_result) is_writable_result = pd.is_writable assert is_writable_result is True or is_writable_result is False reload_result = pd.reload() assert isinstance(reload_result, PrefixData)
def supplement_index_with_repodata(index, repodata, channel, priority): repodata_info = repodata['info'] arch = repodata_info.get('arch') platform = repodata_info.get('platform') subdir = repodata_info.get('subdir') if not subdir: subdir = "%s-%s" % (repodata_info['platform'], repodata_info['arch']) auth = channel.auth for fn, info in iteritems(repodata['packages']): rec = PackageRecord.from_objects(info, fn=fn, arch=arch, platform=platform, channel=channel, subdir=subdir, # schannel=schannel, priority=priority, # url=join_url(channel_url, fn), auth=auth) index[rec] = rec
def test_PrefixData_return_value_contract(): pd = PrefixData(context.conda_prefix) single_prefix_rec = next(pd.iter_records()) get_result = pd.get(PackageRecord.from_objects(single_prefix_rec)) assert isinstance(get_result, PrefixRecord) query_result = pd.query('openssl') assert isinstance(query_result, tuple) assert all(isinstance(prefix_rec, PrefixRecord) for prefix_rec in query_result) iter_records_result = pd.iter_records() assert isiterable(iter_records_result) assert all(isinstance(prefix_rec, PrefixRecord) for prefix_rec in iter_records_result) is_writable_result = pd.is_writable assert is_writable_result is True or is_writable_result is False reload_result = pd.reload() assert isinstance(reload_result, PrefixData)
def test_dist(self): with env_unmodified(conda_tests_ctxt_mgmt_def_pol): dst = Dist('defaults::foo-1.2.3-4.tar.bz2') a = MatchSpec(dst) b = MatchSpec(a) c = MatchSpec(dst, optional=True, target='burg') d = MatchSpec(a, build='5') assert a == b assert hash(a) == hash(b) assert a is b assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d) p = MatchSpec(channel='defaults',name='python',version=VersionSpec('3.5*')) assert p.match(Dist(channel='defaults', dist_name='python-3.5.3-1', name='python', version='3.5.3', build_string='1', build_number=1, base_url=None, platform=None)) assert not p.match(Dist(channel='defaults', dist_name='python-3.6.0-0', name='python', version='3.6.0', build_string='0', build_number=0, base_url=None, platform=None)) assert p.match(Dist(channel='defaults', dist_name='python-3.5.1-0', name='python', version='3.5.1', build_string='0', build_number=0, base_url=None, platform=None)) assert p.match(PackageRecord(name='python', version='3.5.1', build='0', build_number=0, depends=('openssl 1.0.2*', 'readline 6.2*', 'sqlite', 'tk 8.5*', 'xz 5.0.5', 'zlib 1.2*', 'pip'), channel=Channel(scheme='https', auth=None, location='repo.anaconda.com', token=None, name='pkgs/main', platform='osx-64', package_filename=None), subdir='osx-64', fn='python-3.5.1-0.tar.bz2', md5='a813bc0a32691ab3331ac9f37125164c', size=14678857, priority=0, url='https://repo.anaconda.com/pkgs/main/osx-64/python-3.5.1-0.tar.bz2'))
def test_display_actions_0(): os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'False' reset_context(()) actions = defaultdict( list, { "FETCH": [ Dist('channel-1::sympy-0.7.2-py27_0'), Dist("channel-1::numpy-1.7.1-py27_0") ] }) # The older test index doesn't have the size metadata d = Dist.from_string('channel-1::sympy-0.7.2-py27_0.tar.bz2') index[d] = PackageRecord.from_objects(index[d], size=4374752) d = Dist.from_string("channel-1::numpy-1.7.1-py27_0.tar.bz2") index[d] = PackageRecord.from_objects(index[d], size=5994338) with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## The following packages will be downloaded: package | build ---------------------------|----------------- sympy-0.7.2 | py27_0 4.2 MB numpy-1.7.1 | py27_0 5.7 MB ------------------------------------------------------------ Total: 9.9 MB """ actions = defaultdict( list, { 'PREFIX': '/Users/aaronmeurer/anaconda/envs/test', 'SYMLINK_CONDA': ['/Users/aaronmeurer/anaconda'], 'LINK': [ 'channel-1::python-3.3.2-0', 'channel-1::readline-6.2-0 1', 'channel-1::sqlite-3.7.13-0 1', 'channel-1::tk-8.5.13-0 1', 'channel-1::zlib-1.2.7-0 1' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## environment location: /Users/aaronmeurer/anaconda/envs/test The following NEW packages will be INSTALLED: python: 3.3.2-0 \n\ readline: 6.2-0 \n\ sqlite: 3.7.13-0 tk: 8.5.13-0 zlib: 1.2.7-0 \n\ """ actions['UNLINK'] = actions['LINK'] actions['LINK'] = [] with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## environment location: /Users/aaronmeurer/anaconda/envs/test The following packages will be REMOVED: python: 3.3.2-0 \n\ readline: 6.2-0 \n\ sqlite: 3.7.13-0 tk: 8.5.13-0 zlib: 1.2.7-0 \n\ """ actions = defaultdict( list, { 'LINK': ['channel-1::cython-0.19.1-py33_0'], 'UNLINK': ['channel-1::cython-0.19-py33_0'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 """ actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK'] with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## The following packages will be DOWNGRADED: cython: 0.19.1-py33_0 --> 0.19-py33_0 """ actions = defaultdict( list, { 'LINK': [ 'channel-1::cython-0.19.1-py33_0', 'channel-1::dateutil-1.5-py33_0', 'channel-1::numpy-1.7.1-py33_0' ], 'UNLINK': [ 'channel-1::cython-0.19-py33_0', 'channel-1::dateutil-2.1-py33_1', 'channel-1::pip-1.3.1-py33_1' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## The following NEW packages will be INSTALLED: numpy: 1.7.1-py33_0 The following packages will be REMOVED: pip: 1.3.1-py33_1 The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 The following packages will be DOWNGRADED: dateutil: 2.1-py33_1 --> 1.5-py33_0 \n\ """ actions = defaultdict( list, { 'LINK': [ 'channel-1::cython-0.19.1-py33_0', 'channel-1::dateutil-2.1-py33_1' ], 'UNLINK': [ 'channel-1::cython-0.19-py33_0', 'channel-1::dateutil-1.5-py33_0' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ ## Package Plan ## The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 dateutil: 1.5-py33_0 --> 2.1-py33_1 \n\ """ actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK'] with captured() as c: display_actions(actions, index) assert c.stdout == """
CHANNEL_DIR = abspath(join(dirname(__file__), '..', 'data', 'conda_format_repo')) CONDA_PKG_REPO = url_path(CHANNEL_DIR) subdir = "win-64" zlib_base_fn = "zlib-1.2.11-h62dcd97_3" zlib_tar_bz2_fn = "zlib-1.2.11-h62dcd97_3.tar.bz2" zlib_tar_bz2_prec = PackageRecord.from_objects({ "build": "h62dcd97_3", "build_number": 3, "depends": [ "vc >=14.1,<15.0a0" ], "license": "zlib", "license_family": "Other", "md5": "a46cf10ba0eece37dffcec2d45a1f4ec", "name": "zlib", "sha256": "10363f6c023d7fb3d11fdb4cc8de59b5ad5c6affdf960210dd95a252a3fced2b", "size": 131285, "subdir": "win-64", "timestamp": 1542815182812, "version": "1.2.11" }, fn=zlib_tar_bz2_fn, url="%s/%s/%s" % (CONDA_PKG_REPO, subdir, zlib_tar_bz2_fn), ) zlib_conda_fn = "zlib-1.2.11-h62dcd97_3.conda" zlib_conda_prec = PackageRecord.from_objects({ "build": "h62dcd97_3", "build_number": 3, "depends": [ "vc >=14.1,<15.0a0"
def solved_urllib3(): fake = [ PackageRecord( **{ "arch": None, "build": "py36_0", "build_number": 0, "channel": "https://conda.anaconda.org/conda-forge/linux-64", "constrains": [], "depends": [ "certifi", "cryptography >=1.3.4", "idna >=2.0.0", "pyopenssl >=0.14", "pysocks >=1.5.6,<2.0,!=1.5.7", "python >=3.6,<3.7.0a0", ], "fn": "urllib3-1.25.3-py36_0.tar.bz2", "license": "MIT", "license_family": "MIT", "md5": "98696f9f012d04bd7795a6a2febf66a0", "name": "urllib3", "platform": None, "sha256": "d94eb3db911a6806f45a9fba50e49961c189d9fb32c44f8fd19902334616335e", "size": 191254, "subdir": "linux-64", "timestamp": 1558705030958, "url": "https://conda.anaconda.org/conda-forge/linux-64/urllib3-1.25.3-py36_0.tar.bz2", "version": "1.25.3", }), PackageRecord( **{ "arch": None, "build": "py36_0", "build_number": 0, "channel": "https://conda.anaconda.org/conda-forge/linux-64", "constrains": [], "depends": [ "certifi", "cryptography >=1.3.4", "idna >=2.0.0", "pyopenssl >=0.14", "pysocks >=1.5.6,<2.0,!=1.5.7", "python >=3.6,<3.7.0a0", ], "fn": "urllib3-1.25.3-py36_0.tar.bz2", "license": "MIT", "license_family": "MIT", "md5": "98696f9f012d04bd7795a6a2febf66a0", "name": "not-urllib3", "platform": None, "sha256": "d94eb3db911a6806f45a9fba50e49961c189d9fb32c44f8fd19902334616335e", "size": 191254, "subdir": "linux-64", "timestamp": 1558705030958, "url": "https://conda.anaconda.org/conda-forge/linux-64/urllib3-1.25.3-py36_0.tar.bz2", "version": "1.25.3", }), ] return lambda: fake
join(dirname(__file__), '..', 'data', 'conda_format_repo')) CONDA_PKG_REPO = url_path(CHANNEL_DIR) subdir = "win-64" zlib_base_fn = "zlib-1.2.11-h62dcd97_3" zlib_tar_bz2_fn = "zlib-1.2.11-h62dcd97_3.tar.bz2" zlib_tar_bz2_prec = PackageRecord.from_objects( { "build": "h62dcd97_3", "build_number": 3, "depends": ["vc >=14.1,<15.0a0"], "license": "zlib", "license_family": "Other", "md5": "a46cf10ba0eece37dffcec2d45a1f4ec", "name": "zlib", "sha256": "10363f6c023d7fb3d11fdb4cc8de59b5ad5c6affdf960210dd95a252a3fced2b", "size": 131285, "subdir": "win-64", "timestamp": 1542815182812, "version": "1.2.11" }, fn=zlib_tar_bz2_fn, url="%s/%s/%s" % (CONDA_PKG_REPO, subdir, zlib_tar_bz2_fn), ) zlib_conda_fn = "zlib-1.2.11-h62dcd97_3.conda" zlib_conda_prec = PackageRecord.from_objects( { "build": "h62dcd97_3", "build_number": 3, "depends": ["vc >=14.1,<15.0a0"],
def test_display_actions_link_type(): os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'False' reset_context(()) actions = defaultdict( list, { 'LINK': [ 'cython-0.19.1-py33_0 2', 'dateutil-1.5-py33_0 2', 'numpy-1.7.1-py33_0 2', 'python-3.3.2-0 2', 'readline-6.2-0 2', 'sqlite-3.7.13-0 2', 'tk-8.5.13-0 2', 'zlib-1.2.7-0 2' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following NEW packages will be INSTALLED: cython: 0.19.1-py33_0 (softlink) dateutil: 1.5-py33_0 (softlink) numpy: 1.7.1-py33_0 (softlink) python: 3.3.2-0 (softlink) readline: 6.2-0 (softlink) sqlite: 3.7.13-0 (softlink) tk: 8.5.13-0 (softlink) zlib: 1.2.7-0 (softlink) """ actions = defaultdict( list, { 'LINK': ['cython-0.19.1-py33_0 2', 'dateutil-2.1-py33_1 2'], 'UNLINK': ['cython-0.19-py33_0', 'dateutil-1.5-py33_0'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 (softlink) dateutil: 1.5-py33_0 --> 2.1-py33_1 (softlink) """ actions = defaultdict( list, { 'LINK': ['cython-0.19-py33_0 2', 'dateutil-1.5-py33_0 2'], 'UNLINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_1'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be DOWNGRADED: cython: 0.19.1-py33_0 --> 0.19-py33_0 (softlink) dateutil: 2.1-py33_1 --> 1.5-py33_0 (softlink) """ actions = defaultdict( list, { 'LINK': [ 'cython-0.19.1-py33_0 1', 'dateutil-1.5-py33_0 1', 'numpy-1.7.1-py33_0 1', 'python-3.3.2-0 1', 'readline-6.2-0 1', 'sqlite-3.7.13-0 1', 'tk-8.5.13-0 1', 'zlib-1.2.7-0 1' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following NEW packages will be INSTALLED: cython: 0.19.1-py33_0 dateutil: 1.5-py33_0 \n\ numpy: 1.7.1-py33_0 \n\ python: 3.3.2-0 \n\ readline: 6.2-0 \n\ sqlite: 3.7.13-0 \n\ tk: 8.5.13-0 \n\ zlib: 1.2.7-0 \n\ """ actions = defaultdict( list, { 'LINK': ['cython-0.19.1-py33_0 1', 'dateutil-2.1-py33_1 1'], 'UNLINK': ['cython-0.19-py33_0', 'dateutil-1.5-py33_0'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 dateutil: 1.5-py33_0 --> 2.1-py33_1 \n\ """ actions = defaultdict( list, { 'LINK': ['cython-0.19-py33_0 1', 'dateutil-1.5-py33_0 1'], 'UNLINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_1'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be DOWNGRADED: cython: 0.19.1-py33_0 --> 0.19-py33_0 dateutil: 2.1-py33_1 --> 1.5-py33_0 \n\ """ actions = defaultdict( list, { 'LINK': [ 'cython-0.19.1-py33_0 3', 'dateutil-1.5-py33_0 3', 'numpy-1.7.1-py33_0 3', 'python-3.3.2-0 3', 'readline-6.2-0 3', 'sqlite-3.7.13-0 3', 'tk-8.5.13-0 3', 'zlib-1.2.7-0 3' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following NEW packages will be INSTALLED: cython: 0.19.1-py33_0 (copy) dateutil: 1.5-py33_0 (copy) numpy: 1.7.1-py33_0 (copy) python: 3.3.2-0 (copy) readline: 6.2-0 (copy) sqlite: 3.7.13-0 (copy) tk: 8.5.13-0 (copy) zlib: 1.2.7-0 (copy) """ actions = defaultdict( list, { 'LINK': ['cython-0.19.1-py33_0 3', 'dateutil-2.1-py33_1 3'], 'UNLINK': ['cython-0.19-py33_0', 'dateutil-1.5-py33_0'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be UPDATED: cython: 0.19-py33_0 --> 0.19.1-py33_0 (copy) dateutil: 1.5-py33_0 --> 2.1-py33_1 (copy) """ actions = defaultdict( list, { 'LINK': ['cython-0.19-py33_0 3', 'dateutil-1.5-py33_0 3'], 'UNLINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_1'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be DOWNGRADED: cython: 0.19.1-py33_0 --> 0.19-py33_0 (copy) dateutil: 2.1-py33_1 --> 1.5-py33_0 (copy) """ os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'True' reset_context(()) d = Dist('cython-0.19.1-py33_0.tar.bz2') index[d] = PackageRecord.from_objects(index[d], channel='my_channel') d = Dist('dateutil-1.5-py33_0.tar.bz2') index[d] = PackageRecord.from_objects(index[d], channel='my_channel') actions = defaultdict( list, { 'LINK': [ 'cython-0.19.1-py33_0 3', 'dateutil-1.5-py33_0 3', 'numpy-1.7.1-py33_0 3', 'python-3.3.2-0 3', 'readline-6.2-0 3', 'sqlite-3.7.13-0 3', 'tk-8.5.13-0 3', 'zlib-1.2.7-0 3' ] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following NEW packages will be INSTALLED: cython: 0.19.1-py33_0 my_channel (copy) dateutil: 1.5-py33_0 my_channel (copy) numpy: 1.7.1-py33_0 <unknown> (copy) python: 3.3.2-0 <unknown> (copy) readline: 6.2-0 <unknown> (copy) sqlite: 3.7.13-0 <unknown> (copy) tk: 8.5.13-0 <unknown> (copy) zlib: 1.2.7-0 <unknown> (copy) """ actions = defaultdict( list, { 'LINK': ['cython-0.19.1-py33_0 3', 'dateutil-2.1-py33_1 3'], 'UNLINK': ['cython-0.19-py33_0', 'dateutil-1.5-py33_0'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """ The following packages will be UPDATED: cython: 0.19-py33_0 <unknown> --> 0.19.1-py33_0 my_channel (copy) dateutil: 1.5-py33_0 my_channel --> 2.1-py33_1 <unknown> (copy) """ actions = defaultdict( list, { 'LINK': ['cython-0.19-py33_0 3', 'dateutil-1.5-py33_0 3'], 'UNLINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_1'] }) with captured() as c: display_actions(actions, index) assert c.stdout == """