Beispiel #1
0
    def model_with_setup(self, model: MarrmotM01):
        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_soil_moisture_storage=4321,
                start_time="1990-01-01T00:00:00Z",
                end_time="1991-12-31T00:00:00Z",
            )
            return model, cfg_file, cfg_dir
Beispiel #2
0
    def model_with_setup(self, model: MarrmotM01):
        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
Beispiel #3
0
 def model(self, generate_forcing, mocked_config):
     m = MarrmotM01(version="2020.11", forcing=generate_forcing)
     yield m
     if m.bmi:
         # Clean up container
         del m.bmi
Beispiel #4
0
 def test_setup_with_lateend(self, model: MarrmotM01):
     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)
Beispiel #5
0
 def test_setup_with_earlystart(self, model: MarrmotM01):
     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)
Beispiel #6
0
 def test_setup_create_cfg_dir(self, tmp_path, mocked_config, model: MarrmotM01):
     work_dir = tmp_path / "output"
     cfg_file, cfg_dir = model.setup(cfg_dir=str(work_dir))
     assert cfg_dir == str(work_dir)
Beispiel #7
0
 def test_setup_with_own_cfg_dir(self, tmp_path, mocked_config, model: MarrmotM01):
     cfg_file, cfg_dir = model.setup(cfg_dir=str(tmp_path))
     assert cfg_dir == str(tmp_path)