def test_location_retrieve_all(): """Testing for :py:meth:`wwdtm.location.Location.retrieve_all`""" location = Location(connect_dict=get_connect_dict()) locations = location.retrieve_all() assert locations, "No locations could be retrieved" assert "id" in locations[ 0], "'id' was not returned for the first list item"
def test_location_retrieve_all_details(): """Testing for :py:meth:`wwdtm.location.Location.retrieve_all_details`""" location = Location(connect_dict=get_connect_dict()) locations = location.retrieve_all_details() assert locations, "No locations could be retrieved" assert "id" in locations[0], "'id' was not returned for first list item" assert "recordings" in locations[0], ("'recordings' was not returned for " "the first list item")
def test_location_retrieve_by_slug(location_slug: str): """Testing for :py:meth:`wwdtm.location.Location.retrieve_by_slug` :param location_slug: Location slug string to test retrieving location information """ location = Location(connect_dict=get_connect_dict()) info = location.retrieve_by_slug(location_slug) assert info, f"Location slug {location_slug} not found" assert "venue" in info, f"'venue' was not returned for slug {location_slug}"
def test_location_retrieve_details_by_id(location_id: int): """Testing for :py:meth:`wwdtm.location.location.retrieve_details_by_id` :param location_id: Location ID to test retrieving location details """ location = Location(connect_dict=get_connect_dict()) info = location.retrieve_details_by_id(location_id) assert info, f"Location ID {location_id} not found" assert "venue" in info, f"'venue' was not returned for ID {location_id}" assert "recordings" in info, f"'recordings' was not returned for ID {location_id}"
def perf_test_location(connect_dict: Dict[str, Any]) -> float: """Run performance test for the wwdtm.location 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 """ location = Location(connect_dict=connect_dict) # Performance run start time start_time = time.perf_counter() _ = location.retrieve_all() _ = location.retrieve_all_details() _ = location.retrieve_all_ids() _ = location.retrieve_all_slugs() for i in range(3): _ = location.retrieve_by_id(location_id=2) _ = location.retrieve_by_id(location_id=64) for i in range(3): _ = location.retrieve_by_slug( location_slug="chase-auditorium-chicago-il") _ = location.retrieve_by_slug( location_slug="nourse-theater-san-francisco-ca") for i in range(3): _ = location.retrieve_details_by_id(location_id=2) _ = location.retrieve_details_by_id(location_id=64) for i in range(3): _ = location.retrieve_details_by_slug( location_slug="chase-auditorium-chicago-il") _ = location.retrieve_details_by_slug( location_slug="nourse-theater-san-francisco-ca") # Performance run end time end_time = time.perf_counter() return round(end_time - start_time, 5)
def test_location_retrieve_all_slugs(): """Testing for :py:meth:`wwdtm.location.Location.retrieve_all_slugs`""" location = Location(connect_dict=get_connect_dict()) slugs = location.retrieve_all_slugs() assert slugs, "No location slug strings could be retrieved"
def test_location_retrieve_all_ids(): """Testing for :py:meth:`wwdtm.location.Location.retrieve_all_ids`""" location = Location(connect_dict=get_connect_dict()) ids = location.retrieve_all_ids() assert ids, "No location IDs could be retrieved"