|
| 1 | +from tests.papi_data import ( |
| 2 | + CALC_TRACE_DATA_RESPONSE, |
| 3 | + CALC_TRACE_NAME, |
| 4 | + TIME_TRACE_DATA_RESPONSE, |
| 5 | + TIME_TRACE_NAME, |
| 6 | + WELL_NAME, |
| 7 | +) |
| 8 | + |
| 9 | + |
| 10 | +def test_get_time_trace(project): |
| 11 | + start_datetime = '2020-08-31T12:00:00Z' |
| 12 | + end_datetime = '2022-06-10T12:17:43.000Z' |
| 13 | + |
| 14 | + well = project.wells.find_by_name(WELL_NAME) |
| 15 | + assert well is not None |
| 16 | + |
| 17 | + time_traces = well.time_traces |
| 18 | + assert time_traces is not None |
| 19 | + |
| 20 | + traces_data = time_traces.to_dict() |
| 21 | + traces_df = time_traces.to_df() |
| 22 | + assert traces_data |
| 23 | + assert not traces_df.empty |
| 24 | + |
| 25 | + time_trace = time_traces.find_by_name(TIME_TRACE_NAME) |
| 26 | + assert time_trace is not None |
| 27 | + |
| 28 | + trace_points = time_trace.points |
| 29 | + assert trace_points is not None |
| 30 | + |
| 31 | + trace_points_data = trace_points.to_dict() |
| 32 | + assert trace_points_data |
| 33 | + assert len(trace_points_data) == len(trace_points) |
| 34 | + |
| 35 | + trace_points_data = trace_points.to_dict(time_from=start_datetime, time_to=end_datetime) |
| 36 | + trace_points_df = trace_points.to_df(time_from=start_datetime, time_to=end_datetime) |
| 37 | + |
| 38 | + assert trace_points_data |
| 39 | + assert not trace_points_df.empty |
| 40 | + |
| 41 | + point_index = 2 |
| 42 | + point = TIME_TRACE_DATA_RESPONSE['content'][point_index] |
| 43 | + |
| 44 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 45 | + assert trace_points_data[point_index]['index'] == point['index'] |
| 46 | + |
| 47 | + assert trace_points_df.at[point_index, 'value'] == point['value'] |
| 48 | + assert trace_points_df.at[point_index, 'index'] == point['index'] |
| 49 | + |
| 50 | + |
| 51 | +def test_get_calc_trace(project): |
| 52 | + well = project.wells.find_by_name(WELL_NAME) |
| 53 | + assert well is not None |
| 54 | + |
| 55 | + calc_traces = well.calc_traces |
| 56 | + assert calc_traces is not None |
| 57 | + |
| 58 | + traces_data = calc_traces.to_dict() |
| 59 | + traces_df = calc_traces.to_df() |
| 60 | + assert traces_data |
| 61 | + assert not traces_df.empty |
| 62 | + |
| 63 | + calc_trace = calc_traces.find_by_name(CALC_TRACE_NAME) |
| 64 | + assert calc_trace is not None |
| 65 | + |
| 66 | + rac_codes = calc_trace.rac_codes |
| 67 | + assert rac_codes |
| 68 | + |
| 69 | + rac_codes_data = rac_codes.to_dict() |
| 70 | + rac_codes_df = rac_codes.to_df() |
| 71 | + assert rac_codes_data |
| 72 | + assert not rac_codes_df.empty |
| 73 | + |
| 74 | + trace_points = calc_trace.points |
| 75 | + assert trace_points is not None |
| 76 | + |
| 77 | + trace_points_data = trace_points.to_dict() |
| 78 | + trace_points_df = trace_points.to_df() |
| 79 | + assert trace_points_data |
| 80 | + assert not trace_points_df.empty |
| 81 | + assert len(trace_points_data) == len(trace_points_df) == len(CALC_TRACE_DATA_RESPONSE['content']) |
| 82 | + |
| 83 | + |
| 84 | +def test_calc_trace_before_interval(project): |
| 85 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 86 | + assert calc_trace is not None |
| 87 | + |
| 88 | + trace_points = calc_trace.points |
| 89 | + assert trace_points is not None |
| 90 | + |
| 91 | + time_from = '2020-08-01T10:00:00Z' |
| 92 | + time_to = '2020-09-01T10:00:00Z' |
| 93 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 94 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 95 | + assert not trace_points_data |
| 96 | + assert trace_points_df.empty |
| 97 | + |
| 98 | + |
| 99 | +def test_calc_trace_after_interval(project): |
| 100 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 101 | + assert calc_trace is not None |
| 102 | + |
| 103 | + trace_points = calc_trace.points |
| 104 | + assert trace_points is not None |
| 105 | + |
| 106 | + time_from = '2020-09-13T10:53:19Z' |
| 107 | + time_to = '2020-10-13T10:53:19Z' |
| 108 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 109 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 110 | + assert not trace_points_data |
| 111 | + assert trace_points_df.empty |
| 112 | + |
| 113 | + |
| 114 | +def test_calc_trace_interval_boundaries(project): |
| 115 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 116 | + assert calc_trace is not None |
| 117 | + |
| 118 | + trace_points = calc_trace.points |
| 119 | + assert trace_points is not None |
| 120 | + |
| 121 | + point_index = 0 |
| 122 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 123 | + time_from = point['start'] |
| 124 | + time_to = point['end'] |
| 125 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 126 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 127 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 128 | + |
| 129 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 130 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 131 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 132 | + |
| 133 | + point_index = -1 |
| 134 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 135 | + time_from = point['start'] |
| 136 | + time_to = point['end'] |
| 137 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 138 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 139 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 140 | + |
| 141 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 142 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 143 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 144 | + |
| 145 | + |
| 146 | +def test_calc_trace_interval_middle(project): |
| 147 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 148 | + assert calc_trace is not None |
| 149 | + |
| 150 | + trace_points = calc_trace.points |
| 151 | + assert trace_points is not None |
| 152 | + |
| 153 | + time_from = '2020-09-03T11:53:09Z' |
| 154 | + time_to = '2020-09-04T06:11:37Z' |
| 155 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 156 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 157 | + assert len(trace_points_data) == len(trace_points_df) == 2 |
| 158 | + |
| 159 | + for point_index in [1, 2]: |
| 160 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 161 | + assert trace_points_data[point_index - 1]['start'] == point['start'] |
| 162 | + assert trace_points_data[point_index - 1]['end'] == point['end'] |
| 163 | + assert trace_points_data[point_index - 1]['value'] == point['value'] |
| 164 | + |
| 165 | + |
| 166 | +def test_calc_trace_after_interval_start(project): |
| 167 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 168 | + assert calc_trace is not None |
| 169 | + |
| 170 | + trace_points = calc_trace.points |
| 171 | + assert trace_points is not None |
| 172 | + |
| 173 | + time_from = '2020-09-01T10:00:00Z' |
| 174 | + time_to = '2020-09-01T10:00:01Z' |
| 175 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 176 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 177 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 178 | + |
| 179 | + point_index = 0 |
| 180 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 181 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 182 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 183 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 184 | + |
| 185 | + |
| 186 | +def test_calc_trace_after_interval_start_no_time_from(project): |
| 187 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 188 | + assert calc_trace is not None |
| 189 | + |
| 190 | + trace_points = calc_trace.points |
| 191 | + assert trace_points is not None |
| 192 | + |
| 193 | + time_from = None |
| 194 | + time_to = '2020-09-01T10:00:01Z' |
| 195 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 196 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 197 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 198 | + |
| 199 | + point_index = 0 |
| 200 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 201 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 202 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 203 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 204 | + |
| 205 | + |
| 206 | +def test_calc_trace_before_interval_end(project): |
| 207 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 208 | + assert calc_trace is not None |
| 209 | + |
| 210 | + trace_points = calc_trace.points |
| 211 | + assert trace_points is not None |
| 212 | + |
| 213 | + time_from = '2020-09-13T10:53:18Z' |
| 214 | + time_to = '2020-10-13T10:53:19Z' |
| 215 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 216 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 217 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 218 | + |
| 219 | + point_index = -1 |
| 220 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 221 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 222 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 223 | + assert trace_points_data[point_index]['value'] == point['value'] |
| 224 | + |
| 225 | + |
| 226 | +def test_calc_trace_before_interval_end_no_time_to(project): |
| 227 | + calc_trace = project.wells.find_by_name(WELL_NAME).calc_traces.find_by_name(CALC_TRACE_NAME) |
| 228 | + assert calc_trace is not None |
| 229 | + |
| 230 | + trace_points = calc_trace.points |
| 231 | + assert trace_points is not None |
| 232 | + |
| 233 | + time_from = '2020-09-13T10:53:18Z' |
| 234 | + time_to = None |
| 235 | + trace_points_data = trace_points.to_dict(time_from=time_from, time_to=time_to) |
| 236 | + trace_points_df = trace_points.to_df(time_from=time_from, time_to=time_to) |
| 237 | + assert len(trace_points_data) == len(trace_points_df) == 1 |
| 238 | + |
| 239 | + point_index = -1 |
| 240 | + point = CALC_TRACE_DATA_RESPONSE['content'][point_index] |
| 241 | + assert trace_points_data[point_index]['start'] == point['start'] |
| 242 | + assert trace_points_data[point_index]['end'] == point['end'] |
| 243 | + assert trace_points_data[point_index]['value'] == point['value'] |
0 commit comments