Exemplo n.º 1
0
def perf_test_panelist(connect_dict: Dict[str, Any]) -> float:
    """Run performance test for the wwdtm.panelist module

    :param connect_dict: A dictionary containing database connection
        settings for use by mysql.connector
    :type connect_dict: Dict[str, Any]
    :return: Duration of the performance test
    :rtype: float
    """
    panelist = Panelist(connect_dict=connect_dict)
    scores = PanelistScores(connect_dict=connect_dict)

    # Performance run start time
    start_time = time.perf_counter()

    _ = panelist.retrieve_all()
    _ = panelist.retrieve_all_details()
    _ = panelist.retrieve_all_ids()
    _ = panelist.retrieve_all_slugs()

    for i in range(3):
        _ = panelist.retrieve_by_id(panelist_id=5)

    _ = panelist.retrieve_by_id(panelist_id=14)

    for i in range(3):
        _ = panelist.retrieve_by_slug(panelist_slug="adam-felber")

    _ = panelist.retrieve_by_slug(panelist_slug="luke-burbank")

    for i in range(3):
        _ = panelist.retrieve_details_by_id(panelist_id=5)

    _ = panelist.retrieve_details_by_id(panelist_id=14)

    for i in range(3):
        _ = panelist.retrieve_details_by_slug(panelist_slug="adam-felber")

    _ = panelist.retrieve_details_by_slug(panelist_slug="luke-burbank")

    _ = scores.retrieve_scores_by_id(panelist_id=5)
    _ = scores.retrieve_scores_by_slug(panelist_slug="adam-felber")
    _ = scores.retrieve_scores_grouped_list_by_id(panelist_id=5)
    _ = scores.retrieve_scores_grouped_list_by_slug(
        panelist_slug="adam-felber")
    _ = scores.retrieve_scores_grouped_ordered_pair_by_id(panelist_id=5)
    _ = scores.retrieve_scores_grouped_ordered_pair_by_slug(
        panelist_slug="adam-felber")
    _ = scores.retrieve_scores_list_by_id(panelist_id=5)
    _ = scores.retrieve_scores_list_by_slug(panelist_slug="adam-felber")
    _ = scores.retrieve_scores_ordered_pair_by_id(panelist_id=5)
    _ = scores.retrieve_scores_ordered_pair_by_slug(
        panelist_slug="adam-felber")

    # Performance run end time
    end_time = time.perf_counter()
    return round(end_time - start_time, 5)
Exemplo n.º 2
0
def test_panelist_retrieve_by_id(panelist_id: int):
    """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_by_id`

    :param panelist_id: Panelist ID to test retrieving panelist
        information
    """
    panelist = Panelist(connect_dict=get_connect_dict())
    info = panelist.retrieve_by_id(panelist_id)

    assert info, f"Panelist ID {panelist_id} not found"
    assert "name" in info, f"'name' was not returned for ID {panelist_id}"