def test_daylight_saving_time_equality(): """Test the equality of DaylightSavingTime objects.""" daylight_save = DaylightSavingTime() daylight_save_dup = daylight_save.duplicate() daylight_save_alt = DaylightSavingTime(Date(3, 10), Date(11, 3)) assert daylight_save is daylight_save assert daylight_save is not daylight_save_dup assert daylight_save == daylight_save_dup daylight_save_dup.start_date = Date(3, 10) assert daylight_save != daylight_save_dup assert daylight_save != daylight_save_alt
def test_daylight_saving_time_init(): """Test the initialization of DaylightSavingTime and basic properties.""" daylight_save = DaylightSavingTime() str(daylight_save) # test the string representation assert daylight_save.start_date == Date(3, 12) assert daylight_save.end_date == Date(11, 5)
def simulation_par_detailed(directory): sim_par = SimulationParameter() output = SimulationOutput() output.add_zone_energy_use() output.include_html = True output.reporting_frequency = 'Daily' output.add_summary_report('Annual Building Utility Performance Summary') output.add_summary_report('Climatic Data Summary') output.add_summary_report('Envelope Summary') sim_par.output = output run_period = RunPeriod(Date(1, 1), Date(6, 21)) run_period.daylight_saving_time = DaylightSavingTime(Date(3, 12), Date(11, 5)) run_period.start_day_of_week = 'Monday' run_period.holidays = [Date(1, 1), Date(3, 17), Date(7, 4)] sim_par.run_period = run_period sim_par.timestep = 4 sim_control_alt = SimulationControl(run_for_sizing_periods=True, run_for_run_periods=False) sim_par.simulation_control = sim_control_alt shadow_calc_alt = ShadowCalculation( solar_distribution='FullInteriorAndExteriorWithReflections', calculation_method='PixelCounting', calculation_update_method='Timestep') sim_par.shadow_calculation = shadow_calc_alt sizing_alt = SizingParameter(None, 1, 1) relative_path = './scripts/ddy/chicago.ddy' sizing_alt.add_from_ddy_996_004(relative_path) sim_par.sizing_parameter = sizing_alt dest_file = os.path.join(directory, 'simulation_par_detailed.json') with open(dest_file, 'w') as fp: json.dump(sim_par.to_dict(), fp, indent=4)
def test_simulation_parameter_to_dict_detailed(): """Test the to_dict method with a detailed SimulationParameter.""" sim_par = SimulationParameter() output = SimulationOutput() output.add_zone_energy_use() output.include_html = True output.reporting_frequency = 'Daily' output.add_summary_report('Annual Building Utility Performance Summary') output.add_summary_report('Climatic Data Summary') output.add_summary_report('Envelope Summary') sim_par.output = output run_period = RunPeriod(Date(1, 1), Date(6, 21)) run_period.daylight_saving_time = DaylightSavingTime( Date(3, 12), Date(11, 5)) run_period.start_day_of_week = 'Monday' run_period.holidays = [Date(1, 1), Date(3, 17), Date(7, 4)] sim_par.run_period = run_period sim_par.timestep = 4 sim_control_alt = SimulationControl(run_for_sizing_periods=True, run_for_run_periods=False) sim_par.simulation_control = sim_control_alt shadow_calc_alt = ShadowCalculation(calculation_frequency=20) sim_par.shadow_calculation = shadow_calc_alt sizing_alt = SizingParameter(None, 1, 1) relative_path = './tests/ddy/chicago.ddy' sizing_alt.add_from_ddy_996_004(relative_path) sim_par.sizing_parameter = sizing_alt sim_par_dict = sim_par.to_dict() assert 'outputs' in sim_par_dict['output'] assert 'holidays' in sim_par_dict['run_period'] assert 'daylight_saving_time' in sim_par_dict['run_period'] assert 'design_days' in sim_par_dict['sizing_parameter']
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() run_period.is_leap_year = True assert run_period.is_leap_year
def test_simulation_control_dict_methods(): """Test the to/from dict methods.""" daylight_save = DaylightSavingTime(Date(3, 10), Date(11, 3)) ds_dict = daylight_save.to_dict() new_daylight_save = DaylightSavingTime.from_dict(ds_dict) assert new_daylight_save == daylight_save assert ds_dict == new_daylight_save.to_dict()
def test_simulation_control_init_from_idf(): """Test the initialization of SimulationControl from_idf.""" daylight_save = DaylightSavingTime(Date(3, 10), Date(11, 3)) idf_str = daylight_save.to_idf() rebuilt_daylight_save = DaylightSavingTime.from_idf(idf_str) assert daylight_save == rebuilt_daylight_save assert rebuilt_daylight_save.to_idf() == idf_str
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_daylight_saving_time_setability(): """Test the setting of properties of DaylightSavingTime.""" daylight_save = DaylightSavingTime() daylight_save.start_date = Date(3, 10) assert daylight_save.start_date == Date(3, 10) daylight_save.end_date = Date(11, 3) assert daylight_save.end_date == Date(11, 3) with pytest.raises(AssertionError): daylight_save.start_date = Date(11, 10) with pytest.raises(AssertionError): daylight_save.start_date = Date(3, 10, True)
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)