Esempio n. 1
0
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()
Esempio n. 2
0
def test_finder_underscore_on_pkg_name():
    "Finder#handle() should be able to locate packages with underscore on the name"

    # Given a finder component
    finder = Finder(**{"conf": {"pypi_urls": ["http://localhost:8000/simple"]}})

    # When I try to retrieve a package from it
    url = finder.handle("main", {"requirement": "fake_pkg (0.0.0)"})

    # Then I see that the package was downloaded correctly to the storage
    url.should.equal(
        {
            "requirement": "fake_pkg (0.0.0)",
            "locator_url": "http://localhost:8000/simple/",
            "url": "http://localhost:8000/simple/fake-pkg/fake-pkg-0.0.0.tar.gz",
        }
    )
Esempio n. 3
0
def test_finder_underscore_on_pkg_name():
    "Finder#handle() should be able to locate packages with underscore on the name"

    # Given a finder component
    finder = Finder(**{
        'conf': {'pypi_urls': ['http://localhost:8000/simple']},
    })

    # When I try to retrieve a package from it
    url = finder.handle('main', {'requirement': 'fake_pkg (0.0.0)'})

    # Then I see that the package was downloaded correctly to the storage
    url.should.equal({
        'requirement': 'fake_pkg (0.0.0)',
        'locator_url': 'http://localhost:8000/simple/',
        'url': 'http://localhost:8000/simple/fake-pkg/fake-pkg-0.0.0.tar.gz',
    })
Esempio n. 4
0
def test_finder_hyphen_on_pkg_name():
    "Finder#handle() should be able to locate packages with hyphens on the name"

    # Given a finder component
    finder = Finder(**{
        'conf': {'pypi_urls': [DUMMY_PYPI]},
    })

    # When I try to retrieve a package from it
    url = finder.handle('main', {'requirement': 'fake-pkg (0.0.0)'})

    # Then I see that the package was downloaded correctly to the storage
    url.should.equal({
        'requirement': 'fake-pkg (0.0.0)',
        'locator_url': DUMMY_PYPI,
        'url': DUMMY_PYPI_URL('fake-pkg/fake-pkg-0.0.0.tar.gz'),
    })
Esempio n. 5
0
def test_finder_underscore_on_pkg_name():
    "Finder#handle() should be able to locate packages with underscore on the name"

    # Given a finder component
    finder = Finder(**{
        'conf': {
            'pypi_urls': [DUMMY_PYPI]
        },
    })

    # When I try to retrieve a package from it
    url = finder.handle('main', {'requirement': 'fake_pkg (0.0.0)'})

    # Then I see that the package was downloaded correctly to the storage
    url.should.equal({
        'requirement': 'fake_pkg (0.0.0)',
        'locator_url': DUMMY_PYPI,
        'url': DUMMY_PYPI_URL('fake-pkg/fake-pkg-0.0.0.tar.gz'),
    })
Esempio n. 6
0
def test_downloader_with_no_sources():
    "It should be possible to download packages from pip repos with no sources"

    # Given the following downloader component with NO SOURCES
    finder = Finder()

    # When I try to retrieve a package from it, than I see it just blows up
    # with a nice exception
    finder.handle.when.called_with('tests', {
        'requirement': 'gherkin==0.1.0'
    }).should.throw(ReportableError)
Esempio n. 7
0
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()
Esempio n. 8
0
def test_finder_hyphen_on_pkg_name():
    "Finder#handle() should be able to locate packages with hyphens on the name"

    # Given a finder component
    finder = Finder(**{
        'conf': {
            'pypi_urls': ['http://localhost:8000/simple']
        },
    })

    # When I try to retrieve a package from it
    url = finder.handle('main', {'requirement': 'fake-pkg (0.0.0)'})

    # Then I see that the package was downloaded correctly to the storage
    url.should.equal({
        'requirement':
        'fake-pkg (0.0.0)',
        'locator_url':
        'http://localhost:8000/simple/',
        'url':
        'http://localhost:8000/simple/fake-pkg/fake-pkg-0.0.0.tar.gz',
    })
Esempio n. 9
0
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()
Esempio n. 10
0
def test_finder_not_found():
    "Finder#handle() should raise `ReportableError` if it can't find the package"

    # Given a finder component
    finder = Finder(**{
        'conf': {
            'pypi_urls': ['http://localhost:8000/simple']
        },
    })

    # When I try to retrieve a package from it
    finder.handle.when.called_with('main', {
        'requirement': 'donotexist==0.1.0'
    }).should.throw(ReportableError,
                    'Requirement `donotexist==0.1.0\' not found')