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)
def test_material_invalid(): """Test the initalization of EnergyMaterial objects with invalid properties.""" concrete = EnergyMaterial('Concrete', 0.2, 0.5, 800, 0.75) with pytest.raises(TypeError): concrete.name = ['test_name'] 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