diff --git a/tests/geo/test_boozersurface.py b/tests/geo/test_boozersurface.py index 7c40997b3..6c6ea421b 100644 --- a/tests/geo/test_boozersurface.py +++ b/tests/geo/test_boozersurface.py @@ -354,6 +354,27 @@ def subtest_boozer_serialization(self, label): # check that BoozerSurface.surface and label.surface are the same surfaces assert bs_regen.label.surface is bs_regen.surface + def test_run_code(self): + """ + This unit test verifies that the run_code portion of the BoozerSurface class is working as expected + """ + bs, boozer_surface = get_boozer_surface(boozer_type='ls') + boozer_surface.run_code('ls', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False) + + # this second time should not actually run + boozer_surface.run_code('ls', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False) + + bs, boozer_surface = get_boozer_surface(boozer_type='exact') + boozer_surface.run_code('exact', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False) + + # this second time should not actually run + boozer_surface.run_code('exact', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False) + + boozer_surface.need_to_run_code=True + # this should raise an exception + with self.assertRaises(Exception): + boozer_surface.run_code('', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False) + def test_convergence_cpp_and_notcpp_same(self): """ This unit test verifies that that the cpp and not cpp implementations converge to diff --git a/tests/objectives/test_utilities.py b/tests/objectives/test_utilities.py index 8060d0cba..2989523f9 100644 --- a/tests/objectives/test_utilities.py +++ b/tests/objectives/test_utilities.py @@ -112,3 +112,8 @@ def test_mpi_optimizable(self): mpi_surfaces = MPIOptimizable(surfaces, ["x"], comm) for s, sx in zip(mpi_surfaces, equal_to): np.testing.assert_allclose(s.x, sx, atol=1e-14) + + # this should raise an exception + mpi_surfaces = [SurfaceXYZTensorFourier(mpol=1, ntor=1, stellsym=True) for i in range(size)] + with self.assertRaises(Exception): + _ = MPIOptimizable(surfaces, ["y"], comm)