def test_request_install_cached_wheels(): "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-py27-none-any.whl']}} # 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() # When I request an installation of a package env.request_install('gherkin==0.1.0').should.be.false # 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['install'].queue.assert_called_once_with( 'gherkin==0.1.0', 'main', path='storage1/gherkin-0.1.0-py27-none-any.whl') # And that the download queue was not touched env.services['download'].queue.called.should.be.false
def test_request_install_cached_wheels(): "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-py27-none-any.whl'] } } # 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() # When I request an installation of a package env.request_install('gherkin==0.1.0').should.be.false # 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['install'].queue.assert_called_once_with( 'gherkin==0.1.0', 'main', path='storage1/gherkin-0.1.0-py27-none-any.whl') # And that the download queue was not touched env.services['download'].queue.called.should.be.false
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
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')