def test_panelist_retrieve_all(): """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_all`""" panelist = Panelist(connect_dict=get_connect_dict()) panelists = panelist.retrieve_all() assert panelists, "No panelists could be retrieved" assert "id" in panelists[ 0], "'id' was not returned for the first list item"
def test_panelist_retrieve_by_slug(panelist_slug: str): """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_by_slug` :param panelist_slug: Panelist slug string to test retrieving panelist information """ panelist = Panelist(connect_dict=get_connect_dict()) info = panelist.retrieve_by_slug(panelist_slug) assert info, f"Panelist slug {panelist_slug} not found" assert "name" in info, f"'name' was not returned for slug {panelist_slug}"
def test_panelist_retrieve_details_by_id(panelist_id: int): """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_details_by_id` :param panelist_id: Panelist ID to test retrieving panelist details """ panelist = Panelist(connect_dict=get_connect_dict()) info = panelist.retrieve_details_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}" assert "appearances" in info, f"'appearances' was not returned for ID {panelist_id}"
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)
def test_panelist_retrieve_all_slugs(): """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_all_slugs`""" panelist = Panelist(connect_dict=get_connect_dict()) slugs = panelist.retrieve_all_slugs() assert slugs, "No panelist slug strings could be retrieved"
def test_panelist_retrieve_all_ids(): """Testing for :py:meth:`wwdtm.panelist.Panelist.retrieve_all_ids`""" panelist = Panelist(connect_dict=get_connect_dict()) ids = panelist.retrieve_all_ids() assert ids, "No panelist IDs could be retrieved"