def model_with_setup(self, model: MarrmotM14): with patch("datetime.datetime") as mocked_datetime: mocked_datetime.now.return_value = datetime(2021, 1, 2, 3, 4, 5) cfg_file, cfg_dir = model.setup( maximum_soil_moisture_storage=1234, initial_upper_zone_storage=4321, start_time="1990-01-01T00:00:00Z", end_time="1991-12-31T00:00:00Z", ) return model, cfg_file, cfg_dir
def model_with_setup(self, model: MarrmotM14): with patch("datetime.datetime") as mocked_datetime: mocked_datetime.now.return_value = datetime(2021, 1, 2, 3, 4, 5) cfg_file, cfg_dir = model.setup() return model, cfg_file, cfg_dir
def test_setup_with_lateend(self, model: MarrmotM14): with pytest.raises(ValueError) as excinfo: model.setup(end_time="2000-01-01T00:00:00Z", ) assert "end_time outside forcing time range" in str(excinfo.value)
def test_setup_with_earlystart(self, model: MarrmotM14): with pytest.raises(ValueError) as excinfo: model.setup(start_time="1980-01-01T00:00:00Z", ) assert "start_time outside forcing time range" in str(excinfo.value)
def test_setup_create_cfg_dir(self, tmp_path, mocked_config, model: MarrmotM14): work_dir = tmp_path / "output" cfg_file, cfg_dir = model.setup(cfg_dir=str(work_dir)) assert cfg_dir == str(work_dir)
def test_setup_with_own_cfg_dir(self, tmp_path, mocked_config, model: MarrmotM14): cfg_file, cfg_dir = model.setup(cfg_dir=str(tmp_path)) assert cfg_dir == str(tmp_path)