Beispiel #1
0
 def test_get_github_url_owner_and_repo_with_link_in_description(self):
     """Unit test for get_github_URL_owner_and_repo functionality."""
     pythondateutil_pypi_data = get_pypi_data("python-dateutil")
     assert pythondateutil_pypi_data[
         "github_owner_and_repo"] == "dateutil/dateutil"
     rsa_pypi_data = get_pypi_data("rsa")
     assert rsa_pypi_data[
         "github_owner_and_repo"] == "sybrenstuvel/python-rsa"
     py_pypi_data = get_pypi_data("py")
     assert py_pypi_data["github_owner_and_repo"] == "pytest-dev/py"
Beispiel #2
0
def test_print_by_contributor_package(capsys):
    """Unit test for print_by_contributor() for networml python package."""
    pkg = "networkml"
    pypi_data = get_pypi_data(pkg)
    contributors = get_contributors(pypi_data["github_owner_and_repo"])
    print_by_contributor(pkg, contributors, pypi_data=pypi_data)
    captured = capsys.readouterr()  # capture output
    # dedent removes spacing, using the spacing width from the first line
    output_text = textwrap.dedent("""        CONTRIBUTOR, LOCATION
        * indicates PyPI maintainer
        ---------------------
        cglewis * | USA | United States
        anarkiwi | Wellington, New Zealand | New Zealand
        CStephenson970 | None | None
        renovate-bot | None | None
        lilchurro | None | None
        jspeed-meyers * | None | None
        pyup-bot | None | None
        rashley-iqt | None | None
        alshaboti | Wellington, New Zealand | New Zealand
        jseparovic | Mountain View, CA | United States
        squeeve | None | None
        gregs5 | Washington DC | United States
        krb1997 | None | None
        toddstavish | None | None
        sneakyoctopus12 | None | None
        Hax7 | Palestine | Palestine
        paulgowdy | Menlo Park CA | United States\n""")
    assert captured.out == output_text
Beispiel #3
0
 def test_get_github_url_owner_and_repo_with_link_in_description_hyperlinked(
         self):
     """
     Unit test for get_github_URL_owner_and_repo functionality where URL is
     embedded in hypertext
     """
     uritemplate_pypi_data = get_pypi_data("uritemplate")
     assert (uritemplate_pypi_data["github_owner_and_repo"] ==
             "python-hyper/uritemplate")
Beispiel #4
0
def scan_single_package(pkg, summary):
    """Print location results for single package.

    Printing can either be by contributor or by country

    Args:
        pkg - name of python package on PyPI

    Returns:
        null
    """
    pypi_data = get_pypi_data(pkg)
    contributors = get_contributors(pypi_data["github_owner_and_repo"])
    print("-----------------")
    print("PACKAGE: {}".format(pkg))
    print("GITHUB REPO: {}".format(pypi_data["github_owner_and_repo"]))
    print("-----------------")

    if summary:
        print_by_country(contributors)
    else:
        print_by_contributor(contributors, pypi_data)
Beispiel #5
0
def scan_single_package(pkg, summary, num=100):
    """Print location results for single package.

    Printing can either be by contributor or by country.

    Args:
        pkg - name of python package on PyPI
        summary - whether to summarize answers by country or not
        num - max number of contributors to analyze

    Returns:
        null
    """
    pypi_data = get_pypi_data(pkg)
    contributors = get_contributors(pypi_data["github_owner_and_repo"], num)
    print("-----------------")
    print("PACKAGE: {}".format(pkg))
    print("GITHUB REPO: {}".format(pypi_data["github_owner_and_repo"]))
    print("-----------------")

    if summary:
        print_by_country(contributors)
    else:
        print_by_contributor(pkg, contributors, pypi_data=pypi_data)
Beispiel #6
0
 def test_get_pypi_maintainers(self):
     """Unit test for get_pypi_maintainers()."""
     requests_pypi_data = get_pypi_data("pcap2map")
     assert requests_pypi_data["pypi_maintainers"] == ["jspeed-meyers"]
Beispiel #7
0
    def test_get_github_url_owner_and_repo(self):
        """Unit tests for get_github_URL_owner_and_repo()."""
        # tests for packages with standard location of GitHub link on PyPI page
        requests_pypi_data = get_pypi_data("requests")
        assert requests_pypi_data["github_owner_and_repo"] == "psf/requests"
        networkml_pypi_data = get_pypi_data("networkml")
        assert networkml_pypi_data[
            "github_owner_and_repo"] == "IQTLabs/NetworkML"
        pandas_pypi_data = get_pypi_data("pandas")
        assert pandas_pypi_data["github_owner_and_repo"] == "pandas-dev/pandas"
        awscli_pypi_data = get_pypi_data("awscli")
        assert awscli_pypi_data["github_owner_and_repo"] == "aws/aws-cli"
        protobuf_pypi_data = get_pypi_data("protobuf")
        assert protobuf_pypi_data[
            "github_owner_and_repo"] == "protocolbuffers/protobuf"
        pillow_pypi_data = get_pypi_data("pillow")
        assert pillow_pypi_data[
            "github_owner_and_repo"] == "python-pillow/Pillow"
        tornado_pypi_data = get_pypi_data("tornado")
        assert tornado_pypi_data[
            "github_owner_and_repo"] == "tornadoweb/tornado"
        typingextensions_pypi_data = get_pypi_data("typing-extensions")
        assert typingextensions_pypi_data[
            "github_owner_and_repo"] == "python/typing"
        tensorflow_pypi_data = get_pypi_data("tensorflow")
        assert tensorflow_pypi_data[
            "github_owner_and_repo"] == "tensorflow/tensorflow"

        # tests for packages with no GitHub link on PyPI page
        reportlab_pypi_data = get_pypi_data("reportlab")
        assert reportlab_pypi_data["github_owner_and_repo"] == ""
        bfengine_pypi_data = get_pypi_data("bfengine")
        assert bfengine_pypi_data["github_owner_and_repo"] == ""
        docutils_pypi_data = get_pypi_data("docutils")
        assert docutils_pypi_data["github_owner_and_repo"] == ""

        # test for package names that are not on PyPI
        with pytest.raises(Exception):
            get_pypi_data("googlemooglegoogle")