Skip to content

Commit 10fc3b0

Browse files
committed
simplify tests
1 parent 301cba0 commit 10fc3b0

File tree

3 files changed

+36
-90
lines changed

3 files changed

+36
-90
lines changed

test/simulation/test_initialise.py

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -150,96 +150,6 @@ def test_cartesian_and_surface_flux_warning(quantity, sys):
150150
my_model.initialise()
151151

152152

153-
@pytest.mark.parametrize(
154-
"quantity",
155-
[
156-
F.AverageSurfaceCylindrical(field="solute", surface=1),
157-
F.AverageVolumeCylindrical(field="solute", volume=1),
158-
],
159-
)
160-
@pytest.mark.parametrize("sys", ["cartesian", "spherical"])
161-
def test_cylindrical_quantities_warning(quantity, sys):
162-
"""
163-
Creates a Simulation object and checks that, if either a cartesian
164-
or spherical meshes are given with a AverageSurfaceCylindrical, a warning is raised.
165-
166-
Args:
167-
sys (str): type of the coordinate system
168-
"""
169-
# build
170-
my_model = F.Simulation()
171-
my_model.mesh = F.MeshFromVertices([1, 2, 3], type=sys)
172-
my_model.materials = F.Material(id=1, D_0=1, E_D=0)
173-
my_model.T = F.Temperature(100)
174-
my_model.dt = F.Stepsize(initial_value=3)
175-
my_model.settings = F.Settings(
176-
absolute_tolerance=1e-10, relative_tolerance=1e-10, final_time=4
177-
)
178-
179-
derived_quantities = F.DerivedQuantities([quantity])
180-
my_model.exports = [derived_quantities]
181-
182-
# test
183-
with pytest.warns(UserWarning, match=f"may not work as intended for {sys} meshes"):
184-
my_model.initialise()
185-
186-
187-
def test_avg_surf_spherical_quantities_warning():
188-
"""
189-
Creates a Simulation object and checks that, if a cylindrical
190-
mesh is given with a AverageSurfaceSpherical, a warning is raised.
191-
"""
192-
# build
193-
my_model = F.Simulation()
194-
my_model.mesh = F.MeshFromVertices([1, 2, 3], type="cylindrical")
195-
my_model.materials = F.Material(id=1, D_0=1, E_D=0)
196-
my_model.T = F.Temperature(100)
197-
my_model.dt = F.Stepsize(initial_value=3)
198-
my_model.settings = F.Settings(
199-
absolute_tolerance=1e-10, relative_tolerance=1e-10, final_time=4
200-
)
201-
202-
derived_quantities = F.DerivedQuantities(
203-
[F.AverageSurfaceSpherical(field="solute", surface=1)]
204-
)
205-
my_model.exports = [derived_quantities]
206-
207-
# test
208-
with pytest.warns(
209-
UserWarning, match=f"may not work as intended for cylindrical meshes"
210-
):
211-
my_model.initialise()
212-
213-
214-
@pytest.mark.parametrize("sys", ["cartesian", "cylindrical"])
215-
def test_avg_volume_spherical_quantities_warning(sys):
216-
"""
217-
Creates a Simulation object and checks that, if either a cylindrical or
218-
cartesian meshes are given with a AverageVolumeSpherical, a warning is raised.
219-
220-
Args:
221-
sys (str): type of the coordinate system
222-
"""
223-
# build
224-
my_model = F.Simulation()
225-
my_model.mesh = F.MeshFromVertices([1, 2, 3], type=sys)
226-
my_model.materials = F.Material(id=1, D_0=1, E_D=0)
227-
my_model.T = F.Temperature(100)
228-
my_model.dt = F.Stepsize(initial_value=3)
229-
my_model.settings = F.Settings(
230-
absolute_tolerance=1e-10, relative_tolerance=1e-10, final_time=4
231-
)
232-
233-
derived_quantities = F.DerivedQuantities(
234-
[F.AverageVolumeSpherical(field="solute", volume=1)]
235-
)
236-
my_model.exports = [derived_quantities]
237-
238-
# test
239-
with pytest.warns(UserWarning, match=f"may not work as intended for {sys} meshes"):
240-
my_model.initialise()
241-
242-
243153
@pytest.mark.parametrize(
244154
"value",
245155
[

test/unit/test_exports/test_derived_quantities/test_average_surface.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,21 @@ def test_average_surface_spherical_title_no_units_temperature():
180180

181181
my_export = AverageSurfaceSpherical("T", 9)
182182
assert my_export.title == "Average T surface 9 (K)"
183+
184+
185+
def test_avg_surf_cylindrical_allow_meshes():
186+
"""A simple test to check cylindrical meshes are the only
187+
meshes allowed when using AverageSurfaceCylindrical"""
188+
189+
my_export = AverageSurfaceCylindrical("solute", 2)
190+
191+
assert my_export.allowed_meshes == ["cylindrical"]
192+
193+
194+
def test_avg_surf_spherical_allow_meshes():
195+
"""A simple test to check spherical meshes are one of the
196+
meshes allowed when using AverageSurfaceSpherical"""
197+
198+
my_export = AverageSurfaceSpherical("T", 6)
199+
200+
assert "spherical" in my_export.allowed_meshes

test/unit/test_exports/test_derived_quantities/test_average_volume.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,21 @@ def test_average_volume_spherical_title_no_units_temperature():
154154

155155
my_export = AverageVolumeSpherical("T", 9)
156156
assert my_export.title == "Average T volume 9 (K)"
157+
158+
159+
def test_avg_vol_cylindrical_allow_meshes():
160+
"""A simple test to check cylindrical meshes are the only
161+
meshes allowed when using AverageVolumeCylindrical"""
162+
163+
my_export = AverageVolumeCylindrical("solute", 3)
164+
165+
assert my_export.allowed_meshes == ["cylindrical"]
166+
167+
168+
def test_avg_vol_spherical_allow_meshes():
169+
"""A simple test to check cylindrical meshes are the only
170+
meshes allowed when using AverageVolumeSpherical"""
171+
172+
my_export = AverageVolumeSpherical("solute", 5)
173+
174+
assert my_export.allowed_meshes == ["spherical"]

0 commit comments

Comments
 (0)