def test_update_flow_field_time1_iteration1(self, tmp_path): """ Check that the flow in domain is set as expected when no flow (qx & qy==0) """ # create a delta with default settings p = utilities.yaml_from_dict(tmp_path, 'input.yaml') delta = DeltaModel(input_file=p) delta.log_info = mock.MagicMock() # conditions are zero already, but... delta._time_iter = 1 iteration = 1 # run the method qx0 = np.copy(delta.qx) delta.update_flow_field(iteration) # assertions # not sure what to check here other than that something changed assert np.any(delta.qx != qx0) # check inlet boundary conditon assert np.all(delta.qx[0, delta.inlet] == delta.qw0) assert np.all(delta.qy[0, delta.inlet] == 0) assert np.all(delta.qw[0, delta.inlet] == delta.qw0) assert delta.log_info.call_count == 1
def test_update_flow_field_time0_iteration0(self, tmp_path): """ Check that the flow at the inlet is set as expected """ # create a delta with default settings p = utilities.yaml_from_dict(tmp_path, 'input.yaml') delta = DeltaModel(input_file=p) # mock the log delta.log_info = mock.MagicMock() # conditions are zero already, but... delta._time_iter = 0 iteration = 0 # run the method delta.update_flow_field(iteration) # assertions assert np.all(delta.qx[1:, :] == delta.qxn[1:, :]) assert np.all(delta.qy[1:, :] == delta.qyn[1:, :]) # check inlet boundary conditon assert np.all(delta.qx[0, delta.inlet] == delta.qw0) assert np.all(delta.qy[0, delta.inlet] == 0) assert np.all(delta.qw[0, delta.inlet] == delta.qw0) assert delta.log_info.call_count == 1
def test_records_arbitrary_time_values(self, tmp_path, capsys): """ This test should create the log, and then print nothing at all. """ file_name = 'user_parameters.yaml' p, f = utilities.create_temporary_file(tmp_path, file_name) utilities.write_parameter_to_file(f, 'out_dir', tmp_path / 'out_dir') f.close() _delta = DeltaModel(input_file=p) _delta.logger = mock.MagicMock() # change values _delta._time = 3.14159 _delta._time_iter = 42 _delta.log_model_time() # will record whatever value is in _delta _calls = [mock.call('Time: 3.1; timestep: 42')] _delta.logger.info.assert_has_calls(_calls)