def test_run_period_setability(): """Test the setting of properties of RunPeriod.""" run_period = RunPeriod() run_period.start_date = Date(1, 1) assert run_period.start_date == Date(1, 1) run_period.end_date = Date(6, 21) assert run_period.end_date == Date(6, 21) run_period.start_day_of_week = 'Monday' assert run_period.start_day_of_week == 'Monday' run_period.holidays = (Date(1, 1), Date(3, 17)) assert run_period.holidays == (Date(1, 1), Date(3, 17)) run_period.daylight_saving_time = DaylightSavingTime() assert run_period.daylight_saving_time == DaylightSavingTime() with pytest.raises(AssertionError): run_period.start_date = Date(11, 10) with pytest.raises(AssertionError): run_period.start_date = Date(3, 10, True) run_period.is_leap_year = True assert run_period.is_leap_year
def test_run_period_string_methods(): """Test the to/from string methods.""" run_period = RunPeriod() run_period.start_date = Date(1, 1) run_period.end_date = Date(6, 21) run_period.start_day_of_week = 'Monday' run_period.holidays = (Date(1, 1), Date(3, 17)) run_period.daylight_saving_time = DaylightSavingTime() new_run_period = RunPeriod.from_string(str(run_period)) assert new_run_period == run_period
def test_run_period_dict_methods(): """Test the to/from dict methods.""" run_period = RunPeriod() run_period.start_date = Date(1, 1) run_period.end_date = Date(6, 21) run_period.start_day_of_week = 'Monday' run_period.holidays = (Date(1, 1), Date(3, 17)) run_period.daylight_saving_time = DaylightSavingTime() rp_dict = run_period.to_dict() new_run_period = RunPeriod.from_dict(rp_dict) assert new_run_period == run_period assert rp_dict == new_run_period.to_dict()
def test_run_period_init_from_idf(): """Test the initialization of RunPeriod from_idf.""" run_period = RunPeriod() run_period.start_date = Date(1, 1) run_period.end_date = Date(6, 21) run_period.start_day_of_week = 'Monday' run_period.holidays = (Date(1, 1), Date(3, 17)) run_period.daylight_saving_time = DaylightSavingTime() rp_str, holidays, dst = run_period.to_idf() rebuilt_run_period = RunPeriod.from_idf(rp_str, holidays, dst) assert run_period == rebuilt_run_period assert rebuilt_run_period.to_idf() == (rp_str, holidays, dst)