Exemplo n.º 1
0
def test_show_retrieve_years():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_years`"""
    show = Show(connect_dict=get_connect_dict())
    years = show.retrieve_years()

    assert years, "No years could be retrieved"
    assert isinstance(years[0], int), "First list item is not a number"
Exemplo n.º 2
0
def test_show_retrieve_all_show_years_months_tuple():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_all_shows_years_months_tuple`"""
    show = Show(connect_dict=get_connect_dict())
    dates = show.retrieve_all_shows_years_months_tuple()

    assert dates, "No dates could be retrieved"
    assert isinstance(dates[0], tuple), "First list item is not a tuple"
Exemplo n.º 3
0
def test_show_retrieve_recent():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_recent`"""
    show = Show(connect_dict=get_connect_dict())
    shows = show.retrieve_recent()

    assert shows, "No shows could be retrieved"
    assert "id" in shows[0], "No Show ID returned for the first list item"
Exemplo n.º 4
0
def test_show_retrieve_all_details():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_all_details`"""
    show = Show(connect_dict=get_connect_dict())
    shows = show.retrieve_all_details()

    assert shows, "No shows could be retrieved"
    assert "date" in shows[
        0], "'date' was not returned for the first list item"
    assert "host" in shows[0], "'host' was not returned for first list item"
Exemplo n.º 5
0
def test_show_retrieve_months_by_year(year: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_months_by_year`

    :param year: Four digit year to test retrieving a list of months
    """
    show = Show(connect_dict=get_connect_dict())
    months = show.retrieve_months_by_year(year)

    assert months, f"No months could be retrieved for year {year:04d}"
Exemplo n.º 6
0
def test_show_retrieve_by_id(show_id: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_by_id`

    :param show_id: Show ID to test retrieving show information
    """
    show = Show(connect_dict=get_connect_dict())
    info = show.retrieve_by_id(show_id)

    assert info, f"Show ID {show_id} not found"
    assert "date" in info, f"'date' was not returned for ID {show_id}"
Exemplo n.º 7
0
def test_show_retrieve_by_year(year: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_by_year`

    :param year: Four digit year to test retrieving show information
    """
    show = Show(connect_dict=get_connect_dict())
    shows = show.retrieve_by_year(year)

    assert shows, f"No shows could be retrieved for year {year:04d}"
    assert "id" in shows[0], (f"'id' was not returned for the first list item "
                              f"for year {year:04d}")
Exemplo n.º 8
0
def test_show_retrieve_by_date_string(date: str):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_by_date_string`

    :param date: Show date string in ``YYYY-MM-DD`` format to test
        retrieving a show's information
    """
    show = Show(connect_dict=get_connect_dict())
    info = show.retrieve_by_date_string(date)

    assert info, f"Show for date {date} not found"
    assert "date" in info, f"'date' was not returned for show {date}"
Exemplo n.º 9
0
def test_show_retrieve_scores_by_year(year: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_scores_by_year`

    :param year: Four digit year to test retrieving scores for a show
        year
    """
    show = Show(connect_dict=get_connect_dict())
    scores = show.retrieve_scores_by_year(year)

    assert scores, f"No scores could be retrieved by year {year:04d}"
    assert isinstance(scores[0], tuple), "First list item is not a tuple"
Exemplo n.º 10
0
def test_show_retrieve_details_by_month_day(month: int, day: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_details_by_month_day`

    :param month: One or two digit month to test retrieving show details
    :param day: One or two digit day to test retrieving show details
    """
    show = Show(connect_dict=get_connect_dict())
    shows = show.retrieve_details_by_month_day(month, day)

    assert shows, (f"No shows could be retrieved for month {month:02d} "
                   "and day {day:02d}")
    assert "id" in shows[0], (f"'id' was not returned for the first list item "
                              f"for month {month:02d} and day {day:02d}")
Exemplo n.º 11
0
def test_show_retrieve_details_by_year(year: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_details_by_year`

    :param year: Four digit year to test retrieving show details
    """
    show = Show(connect_dict=get_connect_dict())
    info = show.retrieve_details_by_year(year)

    assert info, f"No shows could be retrieved for year {year:04d}"
    assert "date" in info[0], (f"'date' was not returned for first list "
                               f"item for year {year:04d}")
    assert "host" in info[0], (f"'host' was not returned for first list "
                               f"item for year {year:04d}")
Exemplo n.º 12
0
def test_show_retrieve_by_year_month(year: int, month: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_by_year_month`

    :param year: Four digit year to test retrieving show information
    :param month: One or two digit month to test retrieving show
        information
    """
    show = Show(connect_dict=get_connect_dict())
    shows = show.retrieve_by_year_month(year, month)

    assert shows, (f"No shows could be retrieved for year/month "
                   f"{year:04d}-{month:02d}")
    assert "id" in shows[0], (f"'id' was not returned for the first list "
                              f"item for year/month {year:02d}-{month:04d}")
Exemplo n.º 13
0
def test_show_retrieve_by_date(year: int, month: int, day: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_by_date`

    :param year: Four digit year to test retrieving a show's information
    :param month: One or two digit month to test retrieving a show's
        information
    :param day: One or two digit day to test retrieving a show's
        information
    """
    show = Show(connect_dict=get_connect_dict())
    info = show.retrieve_by_date(year, month, day)

    assert info, f"Show for date {year:04d}-{month:02d}-{day:02d} not found"
    assert "date" in info, (f"'date' was not returned for show "
                            f"{year:04d}-{month:02d}-{day:02d}")
Exemplo n.º 14
0
def test_show_retrieve_details_by_year_month(year: int, month: int):
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_details_by_year_month`

    :param year: Four digit year to test retrieving show details
    :param month: One or two digit year to test retrieving show details
    """
    show = Show(connect_dict=get_connect_dict())
    info = show.retrieve_details_by_year_month(year, month)

    assert info, (f"No shows could be retrieved for year/month "
                  f"{year:04d}-{month:02d}")
    assert "date" in info[0], (f"'date' was not returned for first list item "
                               f"for year/month {year:04d}-{month:02d}")
    assert "host" in info[0], (f"'host' was not returned for first list item "
                               f"for year/month {year:04d}-{month:02d}")
Exemplo n.º 15
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)
Exemplo n.º 16
0
def test_show_retrieve_all_dates():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_all_dates`"""
    show = Show(connect_dict=get_connect_dict())
    dates = show.retrieve_all_dates()

    assert dates, "No show dates could be retrieved"
Exemplo n.º 17
0
def test_show_retrieve_all_ids():
    """Testing for :py:meth:`wwdtm.show.Show.retrieve_all_ids`"""
    show = Show(connect_dict=get_connect_dict())
    ids = show.retrieve_all_ids()

    assert ids, "No show IDs could be retrieved"