How to use the pyroma.tests.FakeResponse function in pyroma

To help you get started, we’ve selected a few pyroma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github regebro / pyroma / pyroma / tests.py View on Github external
def urlopenstub(url):
    if url.find("readthedocs.org") != -1:
        host = url.split("/")[2]
        package = host.split(".")[0]
        # Faking the docs:
        if package in ("distribute", "complete"):
            return FakeResponse(200)
        else:
            # This package doesn't have docs on pythonhosted.org:
            return FakeResponse(404)

    if url.startswith("http://pypi.org/project"):
        filename = url[len("http://pypi.org/project/") :]
        # Faking PyPI package
        datafile = resource_filename(
            __name__, os.path.join("testdata", "xmlrpcdata", filename + ".html")
        )
        return FakeResponse(200, datafile)

    if url.startswith("http://pypi.python.org/packages"):
        filename = [x for x in url.split("/") if x][-1]
        # Faking PyPI file downloads
        datafile = resource_filename(
            __name__, os.path.join("testdata", "distributions", filename)
        )
        return FakeResponse(200, datafile)
github regebro / pyroma / pyroma / tests.py View on Github external
if url.startswith("http://pypi.org/project"):
        filename = url[len("http://pypi.org/project/") :]
        # Faking PyPI package
        datafile = resource_filename(
            __name__, os.path.join("testdata", "xmlrpcdata", filename + ".html")
        )
        return FakeResponse(200, datafile)

    if url.startswith("http://pypi.python.org/packages"):
        filename = [x for x in url.split("/") if x][-1]
        # Faking PyPI file downloads
        datafile = resource_filename(
            __name__, os.path.join("testdata", "distributions", filename)
        )
        return FakeResponse(200, datafile)

    raise ValueError("Don't know how to stub " + url)
github regebro / pyroma / pyroma / tests.py View on Github external
def urlopenstub(url):
    if url.find("readthedocs.org") != -1:
        host = url.split("/")[2]
        package = host.split(".")[0]
        # Faking the docs:
        if package in ("distribute", "complete"):
            return FakeResponse(200)
        else:
            # This package doesn't have docs on pythonhosted.org:
            return FakeResponse(404)

    if url.startswith("http://pypi.org/project"):
        filename = url[len("http://pypi.org/project/") :]
        # Faking PyPI package
        datafile = resource_filename(
            __name__, os.path.join("testdata", "xmlrpcdata", filename + ".html")
        )
        return FakeResponse(200, datafile)

    if url.startswith("http://pypi.python.org/packages"):
        filename = [x for x in url.split("/") if x][-1]
        # Faking PyPI file downloads
        datafile = resource_filename(