예제 #1
0
def test_check_duplicate_material_names():
    """Test the check_duplicate_material_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)

    stone = EnergyMaterial('Stone', 0.3, 2.31, 2322, 832, 'Rough', 0.95, 0.75,
                           0.8)
    thin_stone = EnergyMaterial('Thin Stone', 0.05, 2.31, 2322, 832, 'Rough',
                                0.95, 0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Custom Construction', [stone])
    door_constr = OpaqueConstruction('Custom Door Construction', [thin_stone])
    room[0].properties.energy.construction = thermal_mass_constr

    north_face = room[1]
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    door = Door('Front Door', Face3D(door_verts))
    door.properties.energy.construction = door_constr
    north_face.add_door(door)

    model = Model('Tiny House', [room])

    assert model.properties.energy.check_duplicate_material_names(False)
    thin_stone.unlock()
    thin_stone.name = 'Stone'
    thin_stone.lock()
    assert not model.properties.energy.check_duplicate_material_names(False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_material_names(True)
예제 #2
0
def test_material_lockability():
    """Test the lockability of the EnergyMaterial."""
    concrete = EnergyMaterial('Concrete [HW]', 0.2, 0.5, 800, 1200)
    concrete.density = 600
    concrete.lock()
    with pytest.raises(AttributeError):
        concrete.density = 700
    concrete.unlock()
    concrete.density = 700