print(info.types) # {<TimeType.WEEKDAY: 'weekday'>, <TimeType.MONDAY: 'monday'>} print(info.is_weekday) # True print(info.is_weekend) # False print(info.is_morning) # AttributeError: 'WeekInfo' object has no attribute 'is_morning' # Asking for day time info only: info = day_time_info(now) print(info.types) # {<TimeType.AFTERNOON: 'afternoon'>} print(info.is_afternoon) # True print(info.is_evening) # False print(info.is_weekend) # AttributeError: 'DayTimeInfo' object has no attribute 'is_weekend' # Asking for the season e.g. in summer on the southern hemisphere:
def test_time_type_state_is_midmorning(day): """Test day_time_info is_midmorning returns True for midmorning hours""" assert day_time_info(day.hours_0).is_midmorning is False assert day_time_info(day.hours_1).is_midmorning is False assert day_time_info(day.hours_2).is_midmorning is False assert day_time_info(day.hours_3).is_midmorning is False assert day_time_info(day.hours_4).is_midmorning is False assert day_time_info(day.hours_5).is_midmorning is False assert day_time_info(day.hours_6).is_midmorning is False assert day_time_info(day.hours_7).is_midmorning is False assert day_time_info(day.hours_8).is_midmorning is False assert day_time_info(day.hours_9).is_midmorning is False assert day_time_info(day.hours_10).is_midmorning is True assert day_time_info(day.hours_11).is_midmorning is True assert day_time_info(day.hours_12).is_midmorning is False assert day_time_info(day.hours_13).is_midmorning is False assert day_time_info(day.hours_14).is_midmorning is False assert day_time_info(day.hours_15).is_midmorning is False assert day_time_info(day.hours_16).is_midmorning is False assert day_time_info(day.hours_17).is_midmorning is False assert day_time_info(day.hours_18).is_midmorning is False assert day_time_info(day.hours_19).is_midmorning is False assert day_time_info(day.hours_20).is_midmorning is False assert day_time_info(day.hours_21).is_midmorning is False assert day_time_info(day.hours_22).is_midmorning is False assert day_time_info(day.hours_23).is_midmorning is False
def test_time_type_state_is_afternoon(day): """Test day_time_info is_afternoon returns True for afternoon hours""" assert day_time_info(day.hours_0).is_afternoon is False assert day_time_info(day.hours_1).is_afternoon is False assert day_time_info(day.hours_2).is_afternoon is False assert day_time_info(day.hours_3).is_afternoon is False assert day_time_info(day.hours_4).is_afternoon is False assert day_time_info(day.hours_5).is_afternoon is False assert day_time_info(day.hours_6).is_afternoon is False assert day_time_info(day.hours_7).is_afternoon is False assert day_time_info(day.hours_8).is_afternoon is False assert day_time_info(day.hours_9).is_afternoon is False assert day_time_info(day.hours_10).is_afternoon is False assert day_time_info(day.hours_11).is_afternoon is False assert day_time_info(day.hours_12).is_afternoon is False assert day_time_info(day.hours_13).is_afternoon is True assert day_time_info(day.hours_14).is_afternoon is True assert day_time_info(day.hours_15).is_afternoon is True assert day_time_info(day.hours_16).is_afternoon is True assert day_time_info(day.hours_17).is_afternoon is True assert day_time_info(day.hours_18).is_afternoon is False assert day_time_info(day.hours_19).is_afternoon is False assert day_time_info(day.hours_20).is_afternoon is False assert day_time_info(day.hours_21).is_afternoon is False assert day_time_info(day.hours_22).is_afternoon is False assert day_time_info(day.hours_23).is_afternoon is False
def test_time_type_state_types(day): """Test fitting types for the given datetime""" assert day_time_info(day.hours_0).types == {TimeType.NIGHT} assert day_time_info(day.hours_1).types == {TimeType.NIGHT} assert day_time_info(day.hours_2).types == {TimeType.NIGHT} assert day_time_info(day.hours_3).types == {TimeType.NIGHT} assert day_time_info(day.hours_4).types == {TimeType.NIGHT} assert day_time_info(day.hours_5).types == {TimeType.MORNING} assert day_time_info(day.hours_6).types == {TimeType.MORNING} assert day_time_info(day.hours_7).types == {TimeType.MORNING} assert day_time_info(day.hours_8).types == {TimeType.MORNING} assert day_time_info(day.hours_9).types == {TimeType.MORNING} assert day_time_info(day.hours_10).types == {TimeType.MIDMORNING} assert day_time_info(day.hours_11).types == {TimeType.MIDMORNING} assert day_time_info(day.hours_12).types == {TimeType.NOON} assert day_time_info(day.hours_13).types == {TimeType.AFTERNOON} assert day_time_info(day.hours_14).types == {TimeType.AFTERNOON} assert day_time_info(day.hours_15).types == {TimeType.AFTERNOON} assert day_time_info(day.hours_16).types == {TimeType.AFTERNOON} assert day_time_info(day.hours_17).types == {TimeType.AFTERNOON} assert day_time_info(day.hours_18).types == {TimeType.EVENING} assert day_time_info(day.hours_19).types == {TimeType.EVENING} assert day_time_info(day.hours_20).types == {TimeType.EVENING} assert day_time_info(day.hours_21).types == {TimeType.EVENING} assert day_time_info(day.hours_22).types == {TimeType.EVENING} assert day_time_info(day.hours_23).types == {TimeType.NIGHT}