示例#1
0
def test_construction_set_from_standards_dict():
    """Test the from_standards_dict method."""
    constr_set_dict = \
        {
            "name": "2013::ClimateZone5::SteelFramed",
            "wall_set": {
                "exterior_construction": "Typical Insulated Steel Framed Exterior Wall-R19",
                "ground_construction": "Typical Insulated Basement Mass Wall-R8"
            },
            "floor_set": {
                "exterior_construction": "Typical Insulated Steel Framed Exterior Floor-R27",
                "ground_construction": "Typical Insulated Carpeted 8in Slab Floor-R5"
            },
            "roof_ceiling_set": {
                "exterior_construction": "Typical IEAD Roof-R32"
            },
            "aperture_set": {
                "window_construction": "U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm",
                "operable_construction": "U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm",
                "skylight_construction": "Window_U_0.50_SHGC_0.40_Skylight_Frame_Width_0.430_in"
            },
            "door_set": {
                "exterior_construction": "Typical Insulated Metal Door-R2",
                "overhead_construction": "Typical Overhead Door-R2",
                "exterior_glass_construction": "U 0.44 SHGC 0.26 Dbl Ref-B-H Clr 6mm/13mm Air"
            }
        }
    cz5_constr_set = ConstructionSet.from_standards_dict(constr_set_dict)

    assert cz5_constr_set.wall_set.exterior_construction.name == \
        'Typical Insulated Steel Framed Exterior Wall-R19'
    assert cz5_constr_set.wall_set.ground_construction.name == \
        'Typical Insulated Basement Mass Wall-R8'
    assert cz5_constr_set.floor_set.exterior_construction.name == \
        'Typical Insulated Steel Framed Exterior Floor-R27'
    assert cz5_constr_set.floor_set.ground_construction.name == \
        'Typical Insulated Carpeted 8in Slab Floor-R5'
    assert cz5_constr_set.roof_ceiling_set.exterior_construction.name == \
        'Typical IEAD Roof-R32'
    assert cz5_constr_set.door_set.exterior_construction.name == \
        'Typical Insulated Metal Door-R2'
    assert cz5_constr_set.door_set.overhead_construction.name == \
        'Typical Overhead Door-R2'

    assert cz5_constr_set.aperture_set.window_construction.name == \
        'U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm'
    assert cz5_constr_set.aperture_set.operable_construction.name == \
        'U 0.48 SHGC 0.40 Dbl Ref-D Clr 6mm/13mm'
    assert cz5_constr_set.aperture_set.skylight_construction.name == \
        'Window_U_0.50_SHGC_0.40_Skylight_Frame_Width_0.430_in'
    assert cz5_constr_set.door_set.exterior_glass_construction.name == \
        'U 0.44 SHGC 0.26 Dbl Ref-B-H Clr 6mm/13mm Air'
def construction_set_by_identifier(construction_set_identifier):
    """Get a construction_set from the library given its identifier.

    Args:
        construction_set_identifier: A text string for the identifier of
            the ConstructionSet.
    """
    try:  # see if the program type has already been loaded to a Python object
        return _construction_sets[construction_set_identifier]
    except KeyError:  # construction set likely needs to be loaded from standards data
        try:
            _c_set_dict = _construction_set_standards_dict[construction_set_identifier]
        except KeyError:  # program type is nowhere to be found; raise an error
            raise ValueError('"{}" was not found in the construction set library.'.format(
                construction_set_identifier))

    # create the Python object from the standards gem dictionary
    _c_set_obj = ConstructionSet.from_standards_dict(_c_set_dict)
    _c_set_obj.lock()
    _construction_sets[construction_set_identifier] = _c_set_obj  # load faster next time
    return _c_set_obj