コード例 #1
0
def test_check_installed(get_distribution):
    "It should be possible to check if a certain package is currently installed"

    get_distribution.return_value = True
    Env({}).check_installed('gherkin==0.1.0').should.be.true

    get_distribution.side_effect = pkg_resources.VersionConflict
    Env({}).check_installed('gherkin==0.1.0').should.be.false

    get_distribution.side_effect = pkg_resources.DistributionNotFound
    Env({}).check_installed('gherkin==0.1.0').should.be.false
コード例 #2
0
def test_request_install_cached_package():
    "Request the installation of a cached package"

    # Given that I have a loaded local cache
    index = Index('')
    index.storage = {'gherkin': {'0.1.0': ['storage1/gherkin-0.1.0.tar.gz']}}

    # And that I have an environment associated with that local cache
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=False)
    env.services['download'] = Mock()
    env.services['install'] = Mock()
    env.services['curdling'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0')

    # Then I see that, since the package was not installed, the locall cache
    # was queried and returned the right entry
    env.check_installed.assert_called_once_with('gherkin==0.1.0')

    # And I see that the install queue was populated
    env.services['curdling'].queue.assert_called_once_with(
        'gherkin==0.1.0', 'main', path='storage1/gherkin-0.1.0.tar.gz')

    # And that the download queue was not touched
    env.services['download'].queue.called.should.be.false
    env.services['install'].queue.called.should.be.false
コード例 #3
0
ファイル: test_main.py プロジェクト: pombredanne/curdling
def test_request_install_cached_package():
    "Request the installation of a cached package"

    # Given that I have a loaded local cache
    index = Index('')
    index.storage = {'gherkin': {'0.1.0': ['storage1/gherkin-0.1.0.tar.gz']}}

    # And that I have an environment associated with that local cache
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=False)
    env.services['download'] = Mock()
    env.services['install'] = Mock()
    env.services['curdling'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0')

    # Then I see that, since the package was not installed, the locall cache
    # was queried and returned the right entry
    env.check_installed.assert_called_once_with('gherkin==0.1.0')

    # And I see that the install queue was populated
    env.services['curdling'].queue.assert_called_once_with(
        'gherkin==0.1.0', 'main', path='storage1/gherkin-0.1.0.tar.gz')

    # And that the download queue was not touched
    env.services['download'].queue.called.should.be.false
    env.services['install'].queue.called.should.be.false
コード例 #4
0
ファイル: test_main.py プロジェクト: pombredanne/curdling
def test_request_install_installed_package():
    "Request the installation of an already installed package"

    # Given that I have an environment
    index = Mock()
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=True)
    env.services['download'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0').should.be.true

    # Then I see that, since the package was installed, the local cache was not
    # queried
    env.check_installed.assert_called_once_with('gherkin==0.1.0')
    env.index.get.called.should.be.false

    # And then I see that the download queue was not touched
    env.services['download'].queue.called.should.be.false
コード例 #5
0
ファイル: test_main.py プロジェクト: pombredanne/curdling
def test_install_package():
    "It should possible to install wheels"

    # Given that I have an installer configured with a loaded index
    index = Index(FIXTURE('storage2'))
    index.scan()
    installer = Installer(index=index)

    # When I request a curd to be created
    installer.install('gherkin==0.1.0',
                      ('main', {
                          'path': index.get('gherkin==0.1.0;whl')
                      }))

    # Then I see that the package was installed
    Env({}).check_installed('gherkin==0.1.0').should.be.true

    # And I uninstall the package
    Env({}).uninstall('gherkin==0.1.0')
コード例 #6
0
ファイル: test_main.py プロジェクト: pombredanne/curdling
def test_request_install_no_cache():
    "Request the installation of a package when there is no cache"

    # Given that I have an environment
    index = Mock()
    index.get.side_effect = PackageNotFound('gherkin==0.1.0', 'whl')
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=False)
    env.services['download'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0')

    # Then I see that the caches were checked
    env.check_installed.assert_called_once_with('gherkin==0.1.0')
    list(env.index.get.call_args_list).should.equal([
        call('gherkin==0.1.0;whl'),
        call('gherkin==0.1.0;~whl'),
    ])

    # And then I see that the download queue was populated
    env.services['download'].queue.assert_called_once_with(
        'gherkin==0.1.0', 'main')
コード例 #7
0
def test_request_install_installed_package():
    "Request the installation of an already installed package"

    # Given that I have an environment
    index = Mock()
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=True)
    env.services['download'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0').should.be.true

    # Then I see that, since the package was installed, the local cache was not
    # queried
    env.check_installed.assert_called_once_with('gherkin==0.1.0')
    env.index.get.called.should.be.false

    # And then I see that the download queue was not touched
    env.services['download'].queue.called.should.be.false
コード例 #8
0
def test_request_install_no_cache():
    "Request the installation of a package when there is no cache"

    # Given that I have an environment
    index = Mock()
    index.get.side_effect = PackageNotFound('gherkin==0.1.0', 'whl')
    env = Env(conf={'index': index})
    env.check_installed = Mock(return_value=False)
    env.services['download'] = Mock()

    # When I request an installation of a package
    env.request_install('gherkin==0.1.0')

    # Then I see that the caches were checked
    env.check_installed.assert_called_once_with('gherkin==0.1.0')
    list(env.index.get.call_args_list).should.equal([
        call('gherkin==0.1.0;whl'),
        call('gherkin==0.1.0;~whl'),
    ])

    # And then I see that the download queue was populated
    env.services['download'].queue.assert_called_once_with(
        'gherkin==0.1.0', 'main')