|
| 1 | +import pytest |
| 2 | + |
| 3 | +import rips |
| 4 | + |
| 5 | + |
| 6 | +def test_custom_segment_intervals(rips_instance, initialize_test): |
| 7 | + """Test the custom segment intervals Python GRPC interface""" |
| 8 | + |
| 9 | + # Create a test well |
| 10 | + well_path_coll = rips_instance.project.well_path_collection() |
| 11 | + well_path = well_path_coll.add_new_object(rips.ModeledWellPath) |
| 12 | + well_path.name = "Test Well for Custom Segments" |
| 13 | + |
| 14 | + completions_settings = well_path.completion_settings() |
| 15 | + assert completions_settings is not None, "Completion settings should not be None" |
| 16 | + |
| 17 | + # Test creating first interval |
| 18 | + interval1 = completions_settings.add_custom_segment_interval( |
| 19 | + start_md=100, end_md=200 |
| 20 | + ) |
| 21 | + |
| 22 | + # Assertions to verify the first interval |
| 23 | + assert interval1 is not None, "First interval should not be None" |
| 24 | + assert interval1.start_md == 100 |
| 25 | + assert interval1.end_md == 200 |
| 26 | + |
| 27 | + # Test creating a second interval with different values |
| 28 | + interval2 = completions_settings.add_custom_segment_interval( |
| 29 | + start_md=250, end_md=350 |
| 30 | + ) |
| 31 | + |
| 32 | + # Assertions to verify the second interval |
| 33 | + assert interval2 is not None, "Second interval should not be None" |
| 34 | + assert interval2.start_md == 250 |
| 35 | + assert interval2.end_md == 350 |
| 36 | + |
| 37 | + # Test default values |
| 38 | + interval3 = completions_settings.add_custom_segment_interval() |
| 39 | + |
| 40 | + assert interval3 is not None, "Third interval with defaults should not be None" |
| 41 | + assert interval3.start_md == 0.0 |
| 42 | + assert interval3.end_md == 100.0 |
| 43 | + |
| 44 | + |
| 45 | +def test_custom_segment_interval_properties(rips_instance, initialize_test): |
| 46 | + """Test modifying custom segment interval properties""" |
| 47 | + |
| 48 | + # Create a test well |
| 49 | + well_path_coll = rips_instance.project.well_path_collection() |
| 50 | + well_path = well_path_coll.add_new_object(rips.ModeledWellPath) |
| 51 | + well_path.name = "Test Well for Property Modification" |
| 52 | + |
| 53 | + completions_settings = well_path.completion_settings() |
| 54 | + |
| 55 | + # Create an interval |
| 56 | + interval1 = completions_settings.add_custom_segment_interval( |
| 57 | + start_md=100, end_md=200 |
| 58 | + ) |
| 59 | + |
| 60 | + # Test modifying interval properties |
| 61 | + interval1.start_md = 150 |
| 62 | + assert interval1.start_md == 150 |
| 63 | + |
| 64 | + interval1.end_md = 250 |
| 65 | + assert interval1.end_md == 250 |
| 66 | + |
| 67 | + |
| 68 | +def test_custom_segment_interval_invalid_range(rips_instance, initialize_test): |
| 69 | + """Test creating interval with invalid range (start_md > end_md) fails""" |
| 70 | + |
| 71 | + # Create a test well |
| 72 | + well_path_coll = rips_instance.project.well_path_collection() |
| 73 | + well_path = well_path_coll.add_new_object(rips.ModeledWellPath) |
| 74 | + well_path.name = "Test Well for Invalid Range" |
| 75 | + |
| 76 | + completions_settings = well_path.completion_settings() |
| 77 | + |
| 78 | + # Attempt to create an interval with start_md > end_md. Should fail. |
| 79 | + with pytest.raises(rips.RipsError, match="End MD must be greater than Start MD"): |
| 80 | + completions_settings.add_custom_segment_interval(start_md=200, end_md=100) |
| 81 | + |
| 82 | + # Also test equal values (start_md == end_md), which should also fail |
| 83 | + with pytest.raises(rips.RipsError, match="End MD must be greater than Start MD"): |
| 84 | + completions_settings.add_custom_segment_interval(start_md=150, end_md=150) |
0 commit comments