#4468 Python: Add tests for Project plot, export_well_paths, fracture template, summary_cases

Cover four more Project APIs. test_plot_lookup mirrors the existing
views/view test using the WellLogPlot collection in 10KWithWellLog.rsp.
test_export_well_paths exercises the WELLPATHS export-folder path.
test_scale_fracture_template_and_set_containment opens
small-completion-export-fractures.rsp, asserts the scale factors round
trip via PDM descendants, then verifies set_fracture_containment by
saving the project and inspecting the .rsp XML (RimFractureContainment
fields are not scriptable). test_summary_cases uses
SIMPLE_SUMMARY2.SMSPEC and asserts summary_cases() reflects
import_summary_case.
This commit is contained in:
Kristian Bendiksen committed 2026-05-22 14:21:46 +02:00
1 parent 1e14e5b93b
commit 8663cd5d8f
1 file changed
+72
@@ -122,6 +122,78 @@ def test_well_path_by_name(rips_instance, initialize_test):
assert project.well_path_by_name("Nonexistent Well Path") is None
def test_plot_lookup(rips_instance, initialize_test):
project = rips_instance.project.open(
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp"
)
plots = project.plots()
assert len(plots) >= 1
first_plot = plots[0]
looked_up = project.plot(first_plot.id)
assert looked_up is not None
assert looked_up.id == first_plot.id
assert project.plot(999999) is None
def test_export_well_paths(rips_instance, initialize_test):
well_files = [dataroot.PATH + "/TEST10K_FLT_LGR_NNC/wellpath_a.dev"]
rips_instance.project.import_well_paths(well_path_files=well_files)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
rips_instance.set_export_folder(export_type="WELLPATHS", path=tmpdirname)
rips_instance.project.export_well_paths(
well_paths="Well Path A", md_step_size=10.0
)
exported = os.listdir(tmpdirname)
assert any(name.endswith(".dev") for name in exported)
def test_scale_fracture_template_and_set_containment(rips_instance, initialize_test):
project = rips_instance.project.open(
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/small-completion-export-fractures.rsp"
)
template = project.descendants(rips.FractureTemplate)[0]
assert template.height_scale_factor == 1.0
# The half-length scale factor uses the legacy keyword "WidthScaleFactor".
assert template.width_scale_factor == 1.0
assert template.d_factor_scale_factor == 1.0
assert template.conductivity_factor == 1.0
project.scale_fracture_template(
template_id=0, half_length=2.0, height=3.0, d_factor=4.0, conductivity=5.0
)
after_scale = project.descendants(rips.FractureTemplate)[0]
assert after_scale.width_scale_factor == 2.0
assert after_scale.height_scale_factor == 3.0
assert after_scale.d_factor_scale_factor == 4.0
assert after_scale.conductivity_factor == 5.0
project.set_fracture_containment(template_id=0, top_layer=5, base_layer=10)
# RimFractureContainment fields are not scriptable, so verify the change
# made it through by saving the project and inspecting the .rsp XML.
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
out_path = os.path.join(tmpdirname, "containment.rsp")
project.save(out_path)
with open(out_path) as rsp:
content = rsp.read()
assert "<TopKLayer>5</TopKLayer>" in content
assert "<BaseKLayer>10</BaseKLayer>" in content
def test_summary_cases(rips_instance, initialize_test):
case_path = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC"
project = rips_instance.project
assert project.summary_cases() == []
summary_case = project.import_summary_case(case_path)
cases = project.summary_cases()
assert len(cases) == 1
assert cases[0].id == summary_case.id
def test_import_formation_names(rips_instance, initialize_test):
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.load_case(case_path)