def test_contributor_build_with_one_contribution() -> None:
    """
    Create a contributor with one contribution.
    """
    contributor = Contributor("dgarcia360", "http://#",
                              contributions=1).build(_CLASS_NAME)
    assert contributor.astext() == "dgarcia360\n\n1 contribution"
def test_contributor_build() -> None:
    """
    Initializing a contributor.
    """
    contributor = Contributor("dgarcia360", "http://#",
                              contributions=10).build(_CLASS_NAME)
    assert contributor.astext() == "dgarcia360\n\n10 contributions"
def test_contributor_repository_build_with_limit() -> None:
    """
    The limit option works.
    """
    contributors = [
        Contributor("dgarcia360", "http://#", contributions=2),
        Contributor("user", "http://#", contributions=1),
    ]
    contributor_repository = ContributorsRepository(contributors,
                                                    reverse=True,
                                                    limit=1).build(_CLASS_NAME)
    assert contributor_repository.astext() == "dgarcia360\n\n2 contributions"
def test_contributor_repository_build_order_asc() -> None:
    """
    The sort option works (ascending).
    """
    contributors = [
        Contributor("dgarcia360", "http://#", contributions=2),
        Contributor("user", "http://#", 1),
    ]
    contributor_repository = ContributorsRepository(
        contributors, reverse=False).build(_CLASS_NAME)
    assert (contributor_repository.astext() ==
            "user\n\n1 contribution\n\ndgarcia360\n\n2 contributions")
def test_contributor_repository_build() -> None:
    """
    Initializing a repository build.
    """
    contributors = [
        Contributor("dgarcia360", "http://#", contributions=2),
        Contributor("user", "http://#", contributions=1),
    ]
    contributor_repository = ContributorsRepository(
        contributors, reverse=True).build(_CLASS_NAME)
    assert (contributor_repository.astext() ==
            "dgarcia360\n\n2 contributions\n\nuser\n\n1 contribution")
def test_contributor_repository_build_exclude() -> None:
    """
    The exclude option works.
    """
    contributors = [
        Contributor("dgarcia360", "http://#", contributions=2),
        Contributor("sphinx", "http://#", contributions=1),
        Contributor("user", "http://#", contributions=1),
    ]
    exclude = "sphinx,user"
    contributor_repository = ContributorsRepository(
        contributors, reverse=True, limit=10,
        exclude=exclude).build(_CLASS_NAME)
    assert contributor_repository.astext() == "dgarcia360\n\n2 contributions"
def test_contributor_build_with_no_contribution() -> None:
    """
    Create a contributor with no contributions.
    """
    contributor = Contributor("dgarcia360", "http://#").build(_CLASS_NAME)
    assert contributor.astext() == "dgarcia360"