def test_solve_water_and_sediment_timestep_itermax_10(self, tmp_path): # create a delta with different itermax p = utilities.yaml_from_dict(tmp_path, 'input.yaml', {'itermax': 10}) delta = DeltaModel(input_file=p) # mock top-level methods, verify call was made to each delta.log_info = mock.MagicMock() delta.init_water_iteration = mock.MagicMock() delta.run_water_iteration = mock.MagicMock() delta.compute_free_surface = mock.MagicMock() delta.finalize_water_iteration = mock.MagicMock() delta.route_sediment = mock.MagicMock() # run the timestep delta.solve_water_and_sediment_timestep() # assert that methods are called assert delta.init_water_iteration.called is True assert delta.run_water_iteration.called is True assert delta.compute_free_surface.called is True assert delta.finalize_water_iteration.called is True _calls = [mock.call(i) for i in range(10)] delta.finalize_water_iteration.assert_has_calls(_calls, any_order=False) assert delta.finalize_water_iteration.call_count == 10 assert (delta.route_sediment.called is True) assert (delta._is_finalized is False)
def test_route_sediment(self, tmp_path): # create a delta with default settings p = utilities.yaml_from_dict(tmp_path, 'input.yaml') _delta = DeltaModel(input_file=p) # mock top-level methods _delta.log_info = mock.MagicMock() _delta.init_sediment_iteration = mock.MagicMock() _delta.route_all_sand_parcels = mock.MagicMock() _delta.topo_diffusion = mock.MagicMock() _delta.route_all_mud_parcels = mock.MagicMock() # run the method _delta.route_sediment() # methods called assert (_delta.log_info.call_count == 4) assert (_delta.init_sediment_iteration.called is True) assert (_delta.route_all_sand_parcels.called is True) assert (_delta.topo_diffusion.called is True) assert (_delta.route_all_mud_parcels.called is True)
def test_sed_route_deprecated(self, tmp_path): # create a delta with default settings p = utilities.yaml_from_dict(tmp_path, 'input.yaml') _delta = DeltaModel(input_file=p) # mock top-level methods _delta.logger = mock.MagicMock() _delta.route_sediment = mock.MagicMock() # check warning raised with pytest.warns(UserWarning): _delta.sed_route() # and logged assert (_delta.logger.warning.called is True)