def test_material_invalid(): """Test the initialization of EnergyMaterial objects with invalid properties.""" concrete = EnergyMaterial('Concrete', 0.2, 0.5, 800, 1200) with pytest.raises(TypeError): concrete.identifier = ['test_identifier'] with pytest.raises(AssertionError): concrete.thickness = -1 with pytest.raises(AssertionError): concrete.conductivity = -1 with pytest.raises(AssertionError): concrete.density = -1 with pytest.raises(AssertionError): concrete.specific_heat = -1 with pytest.raises(AssertionError): concrete.roughness = 'Medium' with pytest.raises(AssertionError): concrete.thermal_absorptance = 2 with pytest.raises(AssertionError): concrete.solar_absorptance = 2 with pytest.raises(AssertionError): concrete.visible_absorptance = 2 with pytest.raises(AssertionError): concrete.resistivity = -1 with pytest.raises(AssertionError): concrete.u_value = -1 with pytest.raises(AssertionError): concrete.r_value = -1
def test_check_duplicate_material_identifiers(): """Test the check_duplicate_material_identifiers method.""" room = Room.from_box('TinyHouseZone', 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('FrontDoor', Face3D(door_verts)) door.properties.energy.construction = door_constr north_face.add_door(door) model = Model('TinyHouse', [room]) assert model.properties.energy.check_duplicate_material_identifiers(False) thin_stone.unlock() thin_stone.identifier = 'Stone' thin_stone.lock() assert not model.properties.energy.check_duplicate_material_identifiers(False) with pytest.raises(ValueError): model.properties.energy.check_duplicate_material_identifiers(True)