def test_schedule_rule_apply(): """Test the ScheduleRule apply properties.""" simple_office = ScheduleDay( 'Simple Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) sched_rule = ScheduleRule(simple_office) assert not sched_rule.apply_sunday sched_rule.apply_sunday = True assert sched_rule.apply_sunday assert not sched_rule.apply_monday sched_rule.apply_monday = True assert sched_rule.apply_monday assert not sched_rule.apply_tuesday sched_rule.apply_tuesday = True assert sched_rule.apply_tuesday assert not sched_rule.apply_wednesday sched_rule.apply_wednesday = True assert sched_rule.apply_wednesday assert not sched_rule.apply_thursday sched_rule.apply_thursday = True assert sched_rule.apply_thursday assert not sched_rule.apply_friday sched_rule.apply_friday = True assert sched_rule.apply_friday assert not sched_rule.apply_saturday sched_rule.apply_saturday = True assert sched_rule.apply_saturday assert sched_rule.apply_weekday assert sched_rule.apply_weekend assert sched_rule.apply_all
def test_schedule_rule_lockability(): """Test the lockability of the ScheduleRule.""" weekday_office = ScheduleDay( 'Weekday Office Occupancy', [0, 1, 0], [Time(0, 0), Time(9, 0), Time(17, 0)]) weekday_rule = ScheduleRule(weekday_office) weekday_rule.apply_weekday = True weekday_rule.apply_monday = False weekday_rule.lock() with pytest.raises(AttributeError): weekday_rule.apply_monday = True with pytest.raises(AttributeError): weekday_rule.schedule_day.remove_value_by_time(Time(17, 0)) weekday_rule.unlock() weekday_rule.apply_monday = True weekday_rule.schedule_day.remove_value_by_time(Time(17, 0))