예제 #1
0
def test_channel_priority():
    fn1 = 'pandas-0.10.1-np17py27_0.tar.bz2'
    fn2 = 'other::' + fn1
    spec = ['pandas', 'python 2.7*']
    index2 = index.copy()
    index2[Dist(fn2)] = index2[Dist(add_defaults_if_no_channel(fn1))].copy()
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r2 = Resolve(index2)
    rec = r2.index[Dist(fn2)]

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'True'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    # Should select the "other", older package because it
    # has a lower channel priority number
    installed1 = r2.install(spec)
    # Should select the newer package because now the "other"
    # package has a higher priority number
    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=2)
    installed2 = r2.install(spec)
    # Should also select the newer package because we have
    # turned off channel priority altogether

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'False'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    installed3 = r2.install(spec)
    assert installed1 != installed2
    assert installed1 != installed3
    assert installed2 == installed3
예제 #2
0
파일: test_resolve.py 프로젝트: ESSS/conda
def test_channel_priority():
    fn1 = 'pandas-0.10.1-np17py27_0.tar.bz2'
    fn2 = 'other::' + fn1
    spec = ['pandas', 'python 2.7*']
    index2 = index.copy()
    index2[Dist(fn2)] = index2[Dist(fn1)].copy()
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r2 = Resolve(index2)
    rec = r2.index[Dist(fn2)]

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'True'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    # Should select the "other", older package because it
    # has a lower channel priority number
    installed1 = r2.install(spec)
    # Should select the newer package because now the "other"
    # package has a higher priority number
    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=2)
    installed2 = r2.install(spec)
    # Should also select the newer package because we have
    # turned off channel priority altogether

    os.environ['CONDA_CHANNEL_PRIORITY'] = 'False'
    reset_context(())

    r2.index[Dist(fn2)] = IndexRecord.from_objects(r2.index[Dist(fn2)], priority=0)
    installed3 = r2.install(spec)
    assert installed1 != installed2
    assert installed1 != installed3
    assert installed2 == installed3
예제 #3
0
    def test_plan_link_menuinst(self):
        menuinst = Dist('menuinst-1.4.2-py27_0')
        menuinst_record = IndexRecord.from_objects(menuinst)
        ipython = Dist('ipython-5.1.0-py27_1')
        ipython_record = IndexRecord.from_objects(ipython)
        actions = defaultdict(list)
        actions.update({
            'PREFIX': 'aprefix',
            'LINK': [ipython, menuinst],
        })

        conda_plan = plan.plan_from_actions(actions, {
            menuinst: menuinst_record,
            ipython: ipython_record,
        })

        expected_plan = [
            ('PREFIX', 'aprefix'),
            ('PRINT', 'Linking packages ...'),
            # ('PROGRESS', '2'),
            ('PROGRESSIVEFETCHEXTRACT',
             ProgressiveFetchExtract(index, (ipython, menuinst))),
            ('UNLINKLINKTRANSACTION', ((), (ipython), menuinst)),
        ]

        if on_win:
            # menuinst should be linked first
            expected_plan = [
                ('PREFIX', 'aprefix'),
                ('PRINT', 'Linking packages ...'),
                # ('PROGRESS', '1'),
                ('PROGRESSIVEFETCHEXTRACT',
                 ProgressiveFetchExtract(index, (menuinst, ipython))),
                ('UNLINKLINKTRANSACTION', ((), (menuinst, ipython))),
            ]

            # last_two = expected_plan[-2:]
            # expected_plan[-2:] = last_two[::-1]
        assert expected_plan[0] == conda_plan[0]
        assert expected_plan[1] == conda_plan[1]
예제 #4
0
    def test_plan_link_menuinst(self):
        menuinst = Dist('menuinst-1.4.2-py27_0')
        menuinst_record = IndexRecord.from_objects(menuinst)
        ipython = Dist('ipython-5.1.0-py27_1')
        ipython_record = IndexRecord.from_objects(ipython)
        actions = {
            'PREFIX': 'aprefix',
            'LINK': [ipython, menuinst],
        }

        conda_plan = plan.plan_from_actions(actions, {
            menuinst: menuinst_record,
            ipython: ipython_record,
        })

        expected_plan = [
            ('PREFIX', 'aprefix'),
            ('PRINT', 'Linking packages ...'),
            # ('PROGRESS', '2'),
            ('PROGRESSIVEFETCHEXTRACT', ProgressiveFetchExtract(index, (ipython, menuinst))),
            ('UNLINKLINKTRANSACTION', ((), (ipython), menuinst)),
        ]

        if on_win:
            # menuinst should be linked first
            expected_plan = [
                ('PREFIX', 'aprefix'),
                ('PRINT', 'Linking packages ...'),
                # ('PROGRESS', '1'),
                ('PROGRESSIVEFETCHEXTRACT', ProgressiveFetchExtract(index, (menuinst, ipython))),
                ('UNLINKLINKTRANSACTION', ((), (menuinst, ipython))),
            ]

            # last_two = expected_plan[-2:]
            # expected_plan[-2:] = last_two[::-1]
        assert expected_plan[0] == conda_plan[0]
        assert expected_plan[1] == conda_plan[1]
        assert expected_plan[2] == conda_plan[2]
예제 #5
0
def test_broken_install():
    installed = r.install(['pandas', 'python 2.7*', 'numpy 1.6*'])
    assert installed == [Dist(fname) for fname in [
        'dateutil-2.1-py27_1.tar.bz2',
        'numpy-1.6.2-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'pandas-0.11.0-np16py27_1.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'pytz-2013b-py27_0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'scipy-0.12.0-np16py27_0.tar.bz2',
        'six-1.3.0-py27_0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2']]

    # Add a fake package and an incompatible numpy
    installed2 = list(installed)
    installed2[1] = Dist('numpy-1.7.1-py33_p0.tar.bz2')
    installed2.append(Dist('notarealpackage-2.0-0.tar.bz2'))
    assert r.install([], installed2) == installed2
    installed3 = r.install(['numpy'], installed2)
    installed4 = r.remove(['pandas'], installed2)
    assert set(installed4) == set(installed2[:3] + installed2[4:])

    # Remove the installed version of pandas from the index
    index2 = index.copy()
    d = Dist('pandas-0.11.0-np16py27_1.tar.bz2')
    index2[d] = IndexRecord.from_objects(index2[d], priority=MAX_CHANNEL_PRIORITY)
    r2 = Resolve(index2)
    installed2 = r2.install(['pandas', 'python 2.7*', 'numpy 1.6*'], installed)
    assert installed2 == [Dist(d) for d in [
        'dateutil-2.1-py27_1.tar.bz2',
        'numpy-1.6.2-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'pandas-0.10.1-np16py27_0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'pytz-2013b-py27_0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'scipy-0.11.0-np16py27_3.tar.bz2',
        'six-1.3.0-py27_0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2']]
예제 #6
0
def test_broken_install():
    installed = r.install(['pandas', 'python 2.7*', 'numpy 1.6*'])
    assert installed == [Dist(fname) for fname in [
        'dateutil-2.1-py27_1.tar.bz2',
        'numpy-1.6.2-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'pandas-0.11.0-np16py27_1.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'pytz-2013b-py27_0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'scipy-0.12.0-np16py27_0.tar.bz2',
        'six-1.3.0-py27_0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2']]

    # Add a fake package and an incompatible numpy
    installed2 = list(installed)
    installed2[1] = Dist('numpy-1.7.1-py33_p0.tar.bz2')
    installed2.append(Dist('notarealpackage-2.0-0.tar.bz2'))
    assert r.install([], installed2) == installed2
    installed3 = r.install(['numpy'], installed2)
    installed4 = r.remove(['pandas'], installed2)
    assert set(installed4) == set(installed2[:3] + installed2[4:])

    # Remove the installed version of pandas from the index
    index2 = index.copy()
    d = Dist('pandas-0.11.0-np16py27_1.tar.bz2')
    index2[d] = IndexRecord.from_objects(index2[d], priority=MAX_CHANNEL_PRIORITY)
    r2 = Resolve(index2)
    installed2 = r2.install(['pandas', 'python 2.7*', 'numpy 1.6*'], installed)
    assert installed2 == [Dist(d) for d in [
        'dateutil-2.1-py27_1.tar.bz2',
        'numpy-1.6.2-py27_4.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'pandas-0.10.1-np16py27_0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'pytz-2013b-py27_0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'scipy-0.11.0-np16py27_3.tar.bz2',
        'six-1.3.0-py27_0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2']]
예제 #7
0
파일: helpers.py 프로젝트: xstian/conda
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 = IndexRecord.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)
        dist = Dist(rec)
        index[dist] = rec
예제 #8
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] = IndexRecord.from_objects(index[d], channel='my_channel')

    d = Dist('dateutil-1.5-py33_0.tar.bz2')
    index[d] = IndexRecord.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 == """
예제 #9
0
def test_display_actions_show_channel_urls():
    os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'True'
    reset_context(())
    actions = defaultdict(
        list, {"FETCH": ['sympy-0.7.2-py27_0', "numpy-1.7.1-py27_0"]})
    # The older test index doesn't have the size metadata
    d = Dist('sympy-0.7.2-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, size=4374752)
    d = Dist('numpy-1.7.1-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, size=5994338)

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    sympy-0.7.2                |           py27_0         4.2 MB  <unknown>
    numpy-1.7.1                |           py27_0         5.7 MB  <unknown>
    ------------------------------------------------------------
                                           Total:         9.9 MB

"""

    actions = defaultdict(
        list, {
            'PREFIX':
            '/Users/aaronmeurer/anaconda/envs/test',
            'SYMLINK_CONDA': ['/Users/aaronmeurer/anaconda'],
            'LINK': [
                'python-3.3.2-0', 'readline-6.2-0', 'sqlite-3.7.13-0',
                'tk-8.5.13-0', 'zlib-1.2.7-0'
            ]
        })

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """Package plan for environment '/Users/aaronmeurer/anaconda/envs/test':

The following NEW packages will be INSTALLED:

    python:   3.3.2-0  <unknown>
    readline: 6.2-0    <unknown>
    sqlite:   3.7.13-0 <unknown>
    tk:       8.5.13-0 <unknown>
    zlib:     1.2.7-0  <unknown>

"""

    actions['UNLINK'] = actions['LINK']
    actions['LINK'] = []

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """Package plan for environment '/Users/aaronmeurer/anaconda/envs/test':

The following packages will be REMOVED:

    python:   3.3.2-0  <unknown>
    readline: 6.2-0    <unknown>
    sqlite:   3.7.13-0 <unknown>
    tk:       8.5.13-0 <unknown>
    zlib:     1.2.7-0  <unknown>

"""

    actions = defaultdict(list, {
        'LINK': ['cython-0.19.1-py33_0'],
        'UNLINK': ['cython-0.19-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 <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED:

    cython: 0.19.1-py33_0 <unknown> --> 0.19-py33_0 <unknown>

"""

    actions = defaultdict(
        list, {
            'LINK': [
                'cython-0.19.1-py33_0', 'dateutil-1.5-py33_0',
                'numpy-1.7.1-py33_0'
            ],
            'UNLINK':
            ['cython-0.19-py33_0', 'dateutil-2.1-py33_1', 'pip-1.3.1-py33_1']
        })

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following NEW packages will be INSTALLED:

    numpy:    1.7.1-py33_0 <unknown>

The following packages will be REMOVED:

    pip:      1.3.1-py33_1 <unknown>

The following packages will be UPDATED:

    cython:   0.19-py33_0  <unknown> --> 0.19.1-py33_0 <unknown>

The following packages will be DOWNGRADED:

    dateutil: 2.1-py33_1   <unknown> --> 1.5-py33_0    <unknown>

"""

    actions = defaultdict(
        list, {
            'LINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_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 <unknown> --> 0.19.1-py33_0 <unknown>
    dateutil: 1.5-py33_0  <unknown> --> 2.1-py33_1    <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED:

    cython:   0.19.1-py33_0 <unknown> --> 0.19-py33_0 <unknown>
    dateutil: 2.1-py33_1    <unknown> --> 1.5-py33_0  <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    d = Dist('cython-0.19.1-py33_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, channel='my_channel')
    d = Dist('dateutil-1.5-py33_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, channel='my_channel')

    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
    dateutil: 1.5-py33_0  my_channel --> 2.1-py33_1    <unknown> \n\

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
예제 #10
0
def test_display_actions():
    os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'False'
    reset_context(())
    actions = defaultdict(
        list,
        {"FETCH": [Dist('sympy-0.7.2-py27_0'),
                   Dist("numpy-1.7.1-py27_0")]})
    # The older test index doesn't have the size metadata
    d = Dist.from_string('sympy-0.7.2-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(index[d], size=4374752)
    d = Dist.from_string("numpy-1.7.1-py27_0.tar.bz2")
    index[d] = IndexRecord.from_objects(index[d], size=5994338)

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
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': [
                'python-3.3.2-0', '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:

    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 == """
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': ['cython-0.19.1-py33_0'],
        'UNLINK': ['cython-0.19-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

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython: 0.19.1-py33_0 --> 0.19-py33_0

"""

    actions = defaultdict(
        list, {
            'LINK': [
                'cython-0.19.1-py33_0', 'dateutil-1.5-py33_0',
                'numpy-1.7.1-py33_0'
            ],
            'UNLINK':
            ['cython-0.19-py33_0', 'dateutil-2.1-py33_1', 'pip-1.3.1-py33_1']
        })

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
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 due to dependency conflicts:

    dateutil: 2.1-py33_1   --> 1.5-py33_0   \n\

"""

    actions = defaultdict(
        list, {
            'LINK': ['cython-0.19.1-py33_0', 'dateutil-2.1-py33_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['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
예제 #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 due to dependency conflicts:

    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 due to dependency conflicts:

    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 due to dependency conflicts:

    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] = IndexRecord.from_objects(index[d], channel='my_channel')

    d = Dist('dateutil-1.5-py33_0.tar.bz2')
    index[d] = IndexRecord.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 == """
예제 #12
0
def test_display_actions_show_channel_urls():
    os.environ['CONDA_SHOW_CHANNEL_URLS'] = 'True'
    reset_context(())
    actions = defaultdict(list, {"FETCH": ['sympy-0.7.2-py27_0',
        "numpy-1.7.1-py27_0"]})
    # The older test index doesn't have the size metadata
    d = Dist('sympy-0.7.2-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, size=4374752)
    d = Dist('numpy-1.7.1-py27_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, size=5994338)

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    sympy-0.7.2                |           py27_0         4.2 MB  defaults
    numpy-1.7.1                |           py27_0         5.7 MB  defaults
    ------------------------------------------------------------
                                           Total:         9.9 MB

"""

    actions = defaultdict(list, {'PREFIX':
    '/Users/aaronmeurer/anaconda/envs/test', 'SYMLINK_CONDA':
    ['/Users/aaronmeurer/anaconda'], 'LINK': ['python-3.3.2-0', 'readline-6.2-0', 'sqlite-3.7.13-0', 'tk-8.5.13-0', 'zlib-1.2.7-0']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following NEW packages will be INSTALLED:

    python:   3.3.2-0  <unknown>
    readline: 6.2-0    <unknown>
    sqlite:   3.7.13-0 <unknown>
    tk:       8.5.13-0 <unknown>
    zlib:     1.2.7-0  <unknown>

"""

    actions['UNLINK'] = actions['LINK']
    actions['LINK'] = []

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be REMOVED:

    python:   3.3.2-0  <unknown>
    readline: 6.2-0    <unknown>
    sqlite:   3.7.13-0 <unknown>
    tk:       8.5.13-0 <unknown>
    zlib:     1.2.7-0  <unknown>

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0'], 'UNLINK':
    ['cython-0.19-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 <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython: 0.19.1-py33_0 <unknown> --> 0.19-py33_0 <unknown>

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0',
        'dateutil-1.5-py33_0', 'numpy-1.7.1-py33_0'], 'UNLINK':
        ['cython-0.19-py33_0', 'dateutil-2.1-py33_1', 'pip-1.3.1-py33_1']})

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following NEW packages will be INSTALLED:

    numpy:    1.7.1-py33_0 <unknown>

The following packages will be REMOVED:

    pip:      1.3.1-py33_1 <unknown>

The following packages will be UPDATED:

    cython:   0.19-py33_0  <unknown> --> 0.19.1-py33_0 <unknown>

The following packages will be DOWNGRADED due to dependency conflicts:

    dateutil: 2.1-py33_1   <unknown> --> 1.5-py33_0    <unknown>

"""

    actions = defaultdict(list, {'LINK': ['cython-0.19.1-py33_0',
        'dateutil-2.1-py33_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 <unknown> --> 0.19.1-py33_0 <unknown>
    dateutil: 1.5-py33_0  <unknown> --> 2.1-py33_1    <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """
The following packages will be DOWNGRADED due to dependency conflicts:

    cython:   0.19.1-py33_0 <unknown> --> 0.19-py33_0 <unknown>
    dateutil: 2.1-py33_1    <unknown> --> 1.5-py33_0  <unknown>

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    d = Dist('cython-0.19.1-py33_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, channel='my_channel')
    d = Dist('dateutil-1.5-py33_0.tar.bz2')
    index[d] = IndexRecord.from_objects(d, channel='my_channel')

    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
    dateutil: 1.5-py33_0  my_channel --> 2.1-py33_1    <unknown> \n\

"""

    actions['LINK'], actions['UNLINK'] = actions['UNLINK'], actions['LINK']

    with captured() as c:
        display_actions(actions, index)

    assert c.stdout == """