|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +from tests.base_test_case import BaseTestCase |
| 4 | + |
| 5 | +# Ruff disabled because imports are order-dependent |
| 6 | +# ruff: noqa: I001 |
| 7 | +from geophires_x.Model import Model |
| 8 | +from geophires_x.Parameter import ParameterEntry |
| 9 | + |
| 10 | + |
| 11 | +# ruff: noqa: I001 |
| 12 | +from geophires_x.TOUGH2Reservoir import TOUGH2Reservoir |
| 13 | +from geophires_x.OptionList import ReservoirModel |
| 14 | +from geophires_x_client import GeophiresInputParameters |
| 15 | + |
| 16 | +import sys |
| 17 | +import os |
| 18 | + |
| 19 | + |
| 20 | +class Tough2ReservoirTestCase(BaseTestCase): |
| 21 | + def _new_model_with_tough2_reservoir(self, input_file=None) -> Model: |
| 22 | + stash_cwd = Path.cwd() |
| 23 | + stash_sys_argv = sys.argv |
| 24 | + |
| 25 | + sys.argv = [''] |
| 26 | + |
| 27 | + if input_file is not None: |
| 28 | + sys.argv.append(input_file) |
| 29 | + |
| 30 | + m = Model(enable_geophires_logging_config=False) |
| 31 | + m.InputParameters['Reservoir Model'] = ParameterEntry( |
| 32 | + Name='Reservoir Model', sValue=str(ReservoirModel.TOUGH2_SIMULATOR.int_value) |
| 33 | + ) |
| 34 | + m.reserv = TOUGH2Reservoir(m) |
| 35 | + |
| 36 | + if input_file is not None: |
| 37 | + m.read_parameters() |
| 38 | + |
| 39 | + sys.argv = stash_sys_argv |
| 40 | + os.chdir(stash_cwd) |
| 41 | + |
| 42 | + return m |
| 43 | + |
| 44 | + def test_read_inputs(self): |
| 45 | + base_params = GeophiresInputParameters( |
| 46 | + from_file_path=self._get_test_file_path('../examples/example1.txt'), |
| 47 | + params={ |
| 48 | + 'Reservoir Model': ReservoirModel.TOUGH2_SIMULATOR.int_value, |
| 49 | + }, |
| 50 | + ) |
| 51 | + model = self._new_model_with_tough2_reservoir(input_file=base_params.as_file_path()) |
| 52 | + self.assertEqual(model.reserv.tough2_executable_path.value, 'xt2_eos1.exe') |
| 53 | + |
| 54 | + params_custom_exe = GeophiresInputParameters( |
| 55 | + from_file_path=self._get_test_file_path('../examples/example1.txt'), |
| 56 | + params={ |
| 57 | + 'Reservoir Model': ReservoirModel.TOUGH2_SIMULATOR.int_value, |
| 58 | + 'TOUGH2 Executable Path': 'C:\\Users\\my-geophires-project\\tough3-eos1.exe', |
| 59 | + }, |
| 60 | + ) |
| 61 | + model = self._new_model_with_tough2_reservoir(input_file=params_custom_exe.as_file_path()) |
| 62 | + reservoir: TOUGH2Reservoir = model.reserv |
| 63 | + self.assertEqual(reservoir.tough2_executable_path.value, 'C:\\Users\\my-geophires-project\\tough3-eos1.exe') |
0 commit comments