Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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
Beispiel #7
0
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)
Beispiel #8
0
    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"],
Beispiel #9
0
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"
Beispiel #10
0
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 == """
Beispiel #11
0
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 == """