Esempio n. 1
0
def test_show_retrieve_all_show_years_months():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_all_show_years_months`"""
    show = Show(connect_dict=get_connect_dict())
    dates = show.retrieve_all_show_years_months()

    assert dates, "No dates could be retrieved"
    assert isinstance(dates[0], str), "First list item is not a string"
Esempio n. 2
0
def perf_test_show(connect_dict: Dict[str, Any]) -> float:
    """Run performance test for the wwdtm.show 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
    """
    show = Show(connect_dict=connect_dict)

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

    _ = show.retrieve_all()
    _ = show.retrieve_all_details()
    _ = show.retrieve_all_dates()
    _ = show.retrieve_all_dates_tuple()
    _ = show.retrieve_all_ids()
    _ = show.retrieve_all_show_years_months()
    _ = show.retrieve_all_shows_years_months_tuple()

    for i in range(3):
        _ = show.retrieve_by_date(year=2018, month=10, day=27)

    _ = show.retrieve_by_date(year=2006, month=8, day=19)

    for i in range(3):
        _ = show.retrieve_by_date_string(date_string="2018-10-27")

    _ = show.retrieve_by_date_string(date_string="2006-08-19")

    for i in range(3):
        _ = show.retrieve_by_id(show_id=1083)

    _ = show.retrieve_by_id(show_id=47)

    for i in range(3):
        _ = show.retrieve_by_year(year=2018)

    _ = show.retrieve_by_year(year=2006)

    for i in range(3):
        _ = show.retrieve_by_year_month(year=2018, month=10)

    _ = show.retrieve_by_year_month(year=2006, month=8)

    for i in range(3):
        _ = show.retrieve_details_by_date(year=2018, month=10, day=27)

    _ = show.retrieve_details_by_date(year=2006, month=8, day=19)

    for i in range(3):
        _ = show.retrieve_details_by_date_string(date_string="2018-10-27")

    _ = show.retrieve_details_by_date_string(date_string="2006-08-19")

    for i in range(3):
        _ = show.retrieve_details_by_id(show_id=1083)

    _ = show.retrieve_details_by_id(show_id=47)

    for i in range(3):
        _ = show.retrieve_details_by_year(year=2018)

    _ = show.retrieve_details_by_year(year=2006)

    for i in range(3):
        _ = show.retrieve_details_by_year_month(year=2018, month=10)

    _ = show.retrieve_details_by_year_month(year=2018, month=10)

    _ = show.retrieve_recent()
    _ = show.retrieve_recent_details()

    # Performance run end time
    end_time = time.perf_counter()
    return round(end_time - start_time, 5)