def test_curd_package(): "It should possible to convert regular packages to wheels" # Given that I have a storage containing a package index = Index(FIXTURE('storage1')) index.scan() # And a curdling using that index curdling = Curdling(index=index) # When I request a curd to be created package = curdling.wheel('gherkin==0.1.0', ('main', { 'path': index.get('gherkin==0.1.0;~whl') })) # Then I see it's a wheel package. package.should.equal({ 'path': FIXTURE('storage1/gherkin-0.1.0-py27-none-any.whl'), }) # And that it's present in the index package = index.get('gherkin==0.1.0;whl') # And that the file was created in the file system os.path.exists(package).should.be.true # And I delete the file os.unlink(package)
def test_curd_package(): "It should possible to convert regular packages to wheels" # Given that I have a storage containing a package index = Index(FIXTURE('storage1')) index.scan() # And a curdling using that index curdling = Curdler(**{'index': index}) # When I request a curd to be created package = curdling.handle('main', { 'tarball': index.get('gherkin==0.1.0;~whl'), 'requirement': 'gherkin (0.1.0)', }) # Then I see it's a wheel package. package['wheel'].should.match( FIXTURE('storage1/gherkin-0.1.0-py\d{2}-none-any.whl')) # And that it's present in the index package = index.get('gherkin==0.1.0;whl') # And that the file was created in the file system os.path.exists(package).should.be.true # And I delete the file os.unlink(package)
def test_curd_package(): "It should possible to convert regular packages to wheels" # Given that I have a storage containing a package index = Index(FIXTURE('storage1')) index.scan() # And a curdling using that index curdling = Curdling(index=index) # When I request a curd to be created package = curdling.wheel('gherkin==0.1.0', ('main', { 'path': index.get('gherkin==0.1.0;~whl')})) # Then I see it's a wheel package. package.should.equal({ 'path': FIXTURE('storage1/gherkin-0.1.0-py27-none-any.whl'), }) # And that it's present in the index package = index.get('gherkin==0.1.0;whl') # And that the file was created in the file system os.path.exists(package).should.be.true # And I delete the file os.unlink(package)
def test_index_get_corner_case_pkg_name(): "It should be possible to search for packages that contain `_` in their name" # Given that I have an index loaded with a couple package references index = Index("") index.storage = {"python-gherkin": {"0.1.0": ["python_gherkin-0.1.0.tar.gz"]}} index.get("python-gherkin==0.1.0;~whl").should.equal("python_gherkin-0.1.0.tar.gz")
def test_index_scan(): "It should be possible to scan for already existing folders" # Given that I have an index that points to a folder that already contains # packages index = Index(FIXTURE('storage1')) # When I scan the directory index.scan() # Then I can look for packages index.get('gherkin==0.1.0').should.equal( FIXTURE('storage1/gherkin-0.1.0.tar.gz'), )
def test_index_scan(): "It should be possible to scan for already existing folders" # Given that I have an index that points to a folder that already contains # packages index = Index(FIXTURE('storage1')) # When I scan the directory index.scan() # Then I can look for packages index.get('gherkin==0.1.0').should.equal( FIXTURE('storage1/gherkin-0.1.0.tar.gz'), )
def test_index_get_corner_case_pkg_name(): "It should be possible to search for packages that contain `_` in their name" # Given that I have an index loaded with a couple package references index = Index('') index.storage = { 'python-gherkin': { '0.1.0': [ 'python_gherkin-0.1.0.tar.gz', ] } } index.get('python-gherkin==0.1.0;~whl').should.equal('python_gherkin-0.1.0.tar.gz')
def test_index_from_data(): "It should be possible to index data from memory" # Given the following index index = Index(FIXTURE('index')) # When I index a file data = open(FIXTURE('storage1/gherkin-0.1.0.tar.gz'), 'rb').read() index.from_data(path='gherkin-0.1.0.tar.gz', data=data) # Then I see it inside of the index index.get('gherkin==0.1.0').should.equal( FIXTURE('index/gherkin-0.1.0.tar.gz'), ) # And I clean the mess index.delete()
def test_downloader(): "It should be possible to download packages from pip repos" # Given the following downloader component sources = [PipSource(urls=['http://localhost:8000/simple'])] index = Index(FIXTURE('tmpindex')) downloader = DownloadManager(sources=sources, index=index) # When I try to retrieve a package from it package = downloader.retrieve('gherkin==0.1.0', 'main') # Then I see that the package was downloaded correctly to the storage index.get('gherkin==0.1.0').should_not.be.empty # And I cleanup the mess index.delete()
def test_index_from_data(): "It should be possible to index data from memory" # Given the following index index = Index(FIXTURE('index')) # When I index a file data = open(FIXTURE('storage1/gherkin-0.1.0.tar.gz'), 'rb').read() index.from_data(path='gherkin-0.1.0.tar.gz', data=data) # Then I see it inside of the index index.get('gherkin==0.1.0').should.equal( FIXTURE('index/gherkin-0.1.0.tar.gz'), ) # And I clean the mess index.delete()
def test_index_from_file(): "It should be possible to index packages from files" # Given the following index index = Index(FIXTURE('index')) # When I index a file index.from_file(FIXTURE('storage1/gherkin-0.1.0.tar.gz')) # Then I see it inside of the index index.get('gherkin==0.1.0;gz').should.equal( FIXTURE('index/gherkin-0.1.0.tar.gz'), ) # And that there's no wheel available yet index.get.when.called_with('gherkin==0.1.0;whl').should.throw( PackageNotFound, ) # And I clean the mess index.delete()
def test_downloader(): "It should be possible to download packages from pip repos" # Given that I have a finder pointing to our local pypi server finder = Finder(**{"conf": {"pypi_urls": ["http://localhost:8000/simple"]}}) # And a downloader pointing to a temporary index index = Index(FIXTURE("tmpindex")) downloader = Downloader(**{"index": index}) # When I find the link link = finder.handle("tests", {"requirement": "gherkin (== 0.1.0)"}) # And When I try to retrieve a package from it downloader.handle("main", link) # Then I see that the package was downloaded correctly to the storage index.get("gherkin==0.1.0").should_not.be.empty # And I cleanup the mess index.delete()
def test_index_from_file(): "It should be possible to index packages from files" # Given the following index index = Index(FIXTURE('index')) # When I index a file index.from_file(FIXTURE('storage1/gherkin-0.1.0.tar.gz')) # Then I see it inside of the index index.get('gherkin==0.1.0;gz').should.equal( FIXTURE('index/gherkin-0.1.0.tar.gz'), ) # And that there's no wheel available yet index.get.when.called_with('gherkin==0.1.0;whl').should.throw( PackageNotFound, ) # And I clean the mess index.delete()
def test_downloader(): "It should be possible to download packages from pip repos" # Given that I have a finder pointing to our local pypi server finder = Finder(**{ 'conf': {'pypi_urls': ['http://localhost:8000/simple']}, }) # And a downloader pointing to a temporary index index = Index(FIXTURE('tmpindex')) downloader = Downloader(**{'index': index}) # When I find the link link = finder.handle('tests', {'requirement': 'gherkin (== 0.1.0)'}) # And When I try to retrieve a package from it downloader.handle('main', link) # Then I see that the package was downloaded correctly to the storage index.get('gherkin==0.1.0').should_not.be.empty # And I cleanup the mess index.delete()
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.handle("main", {"requirement": "gherkin==0.1.0", "wheel": index.get("gherkin==0.1.0;whl")}) # Then I see that the package was installed Database.check_installed("gherkin==0.1.0").should.be.true # And I uninstall the package Database.uninstall("gherkin==0.1.0")
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')
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')
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.handle('main', { 'requirement': 'gherkin==0.1.0', 'wheel': index.get('gherkin==0.1.0;whl'), }) # Then I see that the package was installed Database.check_installed('gherkin==0.1.0').should.be.true # And I uninstall the package Database.uninstall('gherkin==0.1.0')
def test_index_get(): "It should be possible to search for packages using different criterias" # Given that I have an index loaded with a couple package references index = Index('') index.storage = { 'gherkin': { '0.2.0': [ 'gherkin-0.2.0.tar.gz', ], '0.1.5': [ 'gherkin-0.2.0.tar.gz', ], '0.1.1': [ 'gherkin-0.1.1.tar.gz', ], '0.1.0': [ 'gherkin-0.1.0.tar.gz', 'gherkin-0.1.0-py27-none-any.whl', ], } } # Let's do some random assertions # No version: Always brings the newest index.get('gherkin').should.equal('gherkin-0.2.0.tar.gz') # With a range of versions: Always brings the newest index.get('gherkin>0.1.0').should.equal('gherkin-0.2.0.tar.gz') # With a handful of version specs: Find the matching version and prefer whl index.get('gherkin>=0.1.0,<0.1.5,!=0.1.1').should.equal('gherkin-0.1.0-py27-none-any.whl') # With version: Always prefers the wheel index.get('gherkin==0.1.0,<=0.2.0').should.equal('gherkin-0.1.0-py27-none-any.whl') # With version and format: Prefers anything but `whl' index.get('gherkin==0.1.0;~whl').should.equal('gherkin-0.1.0.tar.gz') # With version range and no format: Finds the highest version with the :) index.get.when.called_with('gherkin==0.1.1;whl').should.throw( PackageNotFound, ( "The index does not have the requested package: " "gherkin==0.1.1 (whl)")) # With version and a format that is not available: Blows up! :) index.get.when.called_with('gherkin==0.1.1;whl').should.throw( PackageNotFound, ( "The index does not have the requested package: " "gherkin==0.1.1 (whl)")) # With a version we simply don't have: Blows up! :) index.get.when.called_with('gherkin==0.2.1').should.throw( PackageNotFound, ( "The index does not have the requested package: " "gherkin==0.2.1")) # With a package we simply don't have: Blows up! :) index.get.when.called_with('nonexisting==0.2.1').should.throw( PackageNotFound, ( "The index does not have the requested package: " "nonexisting==0.2.1"))
def test_index_get(): "It should be possible to search for packages using different criterias" # Given that I have an index loaded with a couple package references index = Index("") index.storage = { "gherkin": { "0.2.0": ["gherkin-0.2.0.tar.gz"], "0.1.5": ["gherkin-0.2.0.tar.gz"], "0.1.1": ["gherkin-0.1.1.tar.gz"], "0.1.0": ["gherkin-0.1.0.tar.gz", "gherkin-0.1.0-py27-none-any.whl"], } } # Let's do some random assertions # No version: Always brings the newest index.get("gherkin").should.equal("gherkin-0.2.0.tar.gz") # With a range of versions: Always brings the newest index.get("gherkin (> 0.1.0)").should.equal("gherkin-0.2.0.tar.gz") # With a handful of version specs: Find the matching version and prefer whl index.get("gherkin (>= 0.1.0, < 0.1.5, != 0.1.1)").should.equal("gherkin-0.1.0-py27-none-any.whl") # With version: Always prefers the wheel index.get("gherkin (== 0.1.0, <= 0.2.0)").should.equal("gherkin-0.1.0-py27-none-any.whl") # With version and format: Prefers anything but `whl' index.get("gherkin (== 0.1.0);~whl").should.equal("gherkin-0.1.0.tar.gz") # With version range and no format: Finds the highest version with the :) index.get.when.called_with("gherkin (== 0.1.1);whl").should.throw( PackageNotFound, ("The index does not have the requested package: " "gherkin (0.1.1) (whl)") ) # With version and a format that is not available: Blows up! :) index.get.when.called_with("gherkin (== 0.1.1);whl").should.throw( PackageNotFound, ("The index does not have the requested package: " "gherkin (0.1.1) (whl)") ) # With a version we simply don't have: Blows up! :) index.get.when.called_with("gherkin (== 0.2.1)").should.throw( PackageNotFound, ("The index does not have the requested package: " "gherkin (0.2.1)") ) # With a package we simply don't have: Blows up! :) index.get.when.called_with("nonexisting (== 0.2.1)").should.throw( PackageNotFound, ("The index does not have the requested package: " "nonexisting (0.2.1)") ) # Case insensitive index.get("Gherkin").should.equal("gherkin-0.2.0.tar.gz")