Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def test_location_retrieve_by_id(location_id: int):
    """Testing for :py:meth:`wwdtm.location.Location.retrieve_by_id`

    :param location_id: Location ID to test retrieving location
        information
    """
    location = Location(connect_dict=get_connect_dict())
    info = location.retrieve_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}"