def test_constructionset_to_dict_full(): """Test the to_dict method writing out all constructions.""" default_set = ConstructionSet('Default Set') constr_dict = default_set.to_dict(none_for_defaults=False) assert constr_dict['wall_set']['exterior_construction'] is not None assert constr_dict['wall_set']['interior_construction'] is not None assert constr_dict['wall_set']['ground_construction'] is not None assert constr_dict['floor_set']['exterior_construction'] is not None assert constr_dict['floor_set']['interior_construction'] is not None assert constr_dict['floor_set']['ground_construction'] is not None assert constr_dict['roof_ceiling_set']['exterior_construction'] is not None assert constr_dict['roof_ceiling_set']['interior_construction'] is not None assert constr_dict['roof_ceiling_set']['ground_construction'] is not None assert constr_dict['aperture_set']['window_construction'] is not None assert constr_dict['aperture_set']['interior_construction'] is not None assert constr_dict['aperture_set']['skylight_construction'] is not None assert constr_dict['aperture_set']['operable_construction'] is not None assert constr_dict['door_set']['exterior_construction'] is not None assert constr_dict['door_set']['interior_construction'] is not None assert constr_dict['door_set']['exterior_glass_construction'] is not None assert constr_dict['door_set']['interior_glass_construction'] is not None assert constr_dict['door_set']['overhead_construction'] is not None assert constr_dict['shade_construction'] is not None
def test_constructionset_dict_methods(): """Test the to/from dict methods.""" insulated_set = ConstructionSet('Insulated Set') clear_glass = EnergyWindowMaterialGlazing( 'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) triple_clear = WindowConstruction( 'Triple Clear Window', [clear_glass, gap, clear_glass, gap, clear_glass]) insulated_set.aperture_set.window_construction = triple_clear constr_dict = insulated_set.to_dict() assert constr_dict['wall_set']['exterior_construction'] is None assert constr_dict['wall_set']['interior_construction'] is None assert constr_dict['wall_set']['ground_construction'] is None assert constr_dict['floor_set']['exterior_construction'] is None assert constr_dict['floor_set']['interior_construction'] is None assert constr_dict['floor_set']['ground_construction'] is None assert constr_dict['roof_ceiling_set']['exterior_construction'] is None assert constr_dict['roof_ceiling_set']['interior_construction'] is None assert constr_dict['roof_ceiling_set']['ground_construction'] is None assert constr_dict['aperture_set']['window_construction'] is not None assert constr_dict['aperture_set']['interior_construction'] is None assert constr_dict['aperture_set']['skylight_construction'] is None assert constr_dict['aperture_set']['operable_construction'] is None assert constr_dict['door_set']['exterior_construction'] is None assert constr_dict['door_set']['interior_construction'] is None assert constr_dict['door_set']['exterior_glass_construction'] is None assert constr_dict['door_set']['interior_glass_construction'] is None assert constr_dict['door_set']['overhead_construction'] is None assert constr_dict['shade_construction'] is None new_constr = ConstructionSet.from_dict(constr_dict) assert constr_dict == new_constr.to_dict()
def test_from_dict_non_abridged(): """Test the Model from_dict method with non-abridged objects.""" first_floor = Room.from_box('FirstFloor', 10, 10, 3, origin=Point3D(0, 0, 0)) second_floor = Room.from_box('SecondFloor', 10, 10, 3, origin=Point3D(0, 0, 3)) first_floor.properties.energy.program_type = office_program second_floor.properties.energy.program_type = office_program first_floor.properties.energy.add_default_ideal_air() second_floor.properties.energy.add_default_ideal_air() for face in first_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) for face in second_floor[1:5]: face.apertures_by_ratio(0.2, 0.01) pts_1 = [Point3D(0, 0, 6), Point3D(0, 10, 6), Point3D(10, 10, 6), Point3D(10, 0, 6)] pts_2 = [Point3D(0, 0, 6), Point3D(5, 0, 9), Point3D(5, 10, 9), Point3D(0, 10, 6)] pts_3 = [Point3D(10, 0, 6), Point3D(10, 10, 6), Point3D(5, 10, 9), Point3D(5, 0, 9)] pts_4 = [Point3D(0, 0, 6), Point3D(10, 0, 6), Point3D(5, 0, 9)] pts_5 = [Point3D(10, 10, 6), Point3D(0, 10, 6), Point3D(5, 10, 9)] face_1 = Face('AtticFace1', Face3D(pts_1)) face_2 = Face('AtticFace2', Face3D(pts_2)) face_3 = Face('AtticFace3', Face3D(pts_3)) face_4 = Face('AtticFace4', Face3D(pts_4)) face_5 = Face('AtticFace5', Face3D(pts_5)) attic = Room('Attic', [face_1, face_2, face_3, face_4, face_5], 0.01, 1) constr_set = ConstructionSet('Attic Construction Set') polyiso = EnergyMaterial('PolyIso', 0.2, 0.03, 43, 1210, 'MediumRough') roof_constr = OpaqueConstruction('Attic Roof Construction', [roof_membrane, polyiso, wood]) floor_constr = OpaqueConstruction('Attic Floor Construction', [wood, insulation, wood]) constr_set.floor_set.interior_construction = floor_constr constr_set.roof_ceiling_set.exterior_construction = roof_constr attic.properties.energy.construction_set = constr_set Room.solve_adjacency([first_floor, second_floor, attic], 0.01) model = Model('MultiZoneSingleFamilyHouse', [first_floor, second_floor, attic]) model_dict = model.to_dict() model_dict['properties']['energy']['program_types'][0] = office_program.to_dict() model_dict['properties']['energy']['construction_sets'][0] = constr_set.to_dict() rebuilt_model = Model.from_dict(model_dict) assert rebuilt_model.rooms[0].properties.energy.program_type == office_program assert rebuilt_model.rooms[2].properties.energy.construction_set == constr_set
def test_dict_to_object_constr_set(): """Test the dict_to_object method with ConstructionSet objects.""" constr_set_obj = ConstructionSet('Test ConstructionSet') constr_set_dict = constr_set_obj.to_dict() new_constr_set = dict_to_object(constr_set_dict) assert isinstance(new_constr_set, ConstructionSet)