Skip to content

Commit bf627d4

Browse files
committed
Clean up db tests
1 parent 5aabff9 commit bf627d4

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

threedigrid_builder/interface/db.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,22 +832,28 @@ def get_pumps(self) -> Pumps:
832832
models.Pump.code,
833833
models.Pump.capacity,
834834
models.Pump.connection_node_id,
835-
# models.Pumpstation.connection_node_id_end,
835+
models.PumpMap.connection_node_id_end,
836836
models.Pump.type_,
837837
models.Pump.start_level,
838838
models.Pump.lower_stop_level,
839839
models.Pump.upper_stop_level,
840840
models.Pump.display_name,
841841
)
842+
.join(models.PumpMap, models.Pump.id == models.PumpMap.pump_id)
842843
.order_by(models.Pump.id)
843844
.as_structarray()
844845
)
845-
# TODO get connection_node_id_end
846-
# Pump capicity is entered as L/s but we need m3/s.
846+
847+
# Pump capacity is entered as L/s but we need m3/s.
847848
arr["capacity"] = arr["capacity"] / 1000
848849

849850
attr_dict = arr_to_attr_dict(
850-
arr, {"connection_node_id": "connection_node_start_id", "geom": "the_geom"}
851+
arr,
852+
{
853+
"connection_node_id": "connection_node_start_id",
854+
"connection_node_id_end": "connection_node_end_id",
855+
"geom": "the_geom",
856+
},
851857
)
852858

853859
# transform to a Pumps object

threedigrid_builder/tests/test_db.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ def test_get_connection_nodes(db):
134134
assert np.isnan(connection_nodes.bottom_level[100])
135135
assert connection_nodes.drain_level[1] == -0.82
136136
assert connection_nodes.surface_level[35] == -0.54
137-
# TODO:
138-
# assert connection_nodes.shape[40] == "00"
139-
# assert connection_nodes.width[32] == 0.8
140137
assert connection_nodes.display_name[33] == "71512"
141138

142139

@@ -174,8 +171,6 @@ def test_get_cross_section_locations(db):
174171
locations.the_geom[96], shapely.from_wkt("POINT (111104 521655)"), tolerance=1
175172
)
176173
assert locations.id[11] == 12
177-
# TODO: fix
178-
# assert locations.definition_id[365] == 98
179174
assert locations.channel_id[448] == 452
180175
assert locations.reference_level[691] == -3.0
181176
assert locations.bank_level[995] == -1.7
@@ -233,8 +228,6 @@ def test_get_pipes(db):
233228
assert pipes.calculation_type[3] == CalculationType.ISOLATED
234229
assert pipes.connection_node_start_id[4] == 37
235230
assert pipes.connection_node_end_id[5] == 35
236-
# TODO: fix this
237-
# assert pipes.cross_section_definition_id[9] == 7
238231
assert pipes.invert_level_start_point[16] == -3.91
239232
assert pipes.invert_level_end_point[19] == -3.62
240233
assert pipes.sewerage_type[24] == 2
@@ -317,21 +310,18 @@ def test_get_settings(db):
317310
def test_get_pumps(db):
318311
pumps = db.get_pumps()
319312
assert isinstance(pumps, Pumps)
320-
321313
# some test samples
322-
assert len(pumps) == 19
323-
assert pumps.id[11] == 13
324-
assert pumps.code[0] == "Rioolgemaal"
325-
assert pumps.capacity[12] == 0.288
326-
assert pumps.connection_node_start_id[13] == 1006
327-
# TODO fix
328-
# assert pumps.connection_node_end_id[0] == -9999 # NULL handling
329-
# assert pumps.connection_node_end_id[2] == 218
330-
assert pumps.type_[5] == 1
331-
assert pumps.start_level[0] == -4.0
332-
assert pumps.lower_stop_level[18] == -1.9
333-
assert np.isnan(pumps.upper_stop_level[15])
334-
assert pumps.display_name[10] == "KGM-JL-18"
314+
assert len(pumps) == 18
315+
assert pumps.id[10] == 13
316+
assert pumps.code[0] == "110"
317+
assert pumps.capacity[11] == 0.288
318+
assert pumps.connection_node_start_id[12] == 1006
319+
assert pumps.connection_node_end_id[1] == 218
320+
assert pumps.type_[4] == 1
321+
assert pumps.start_level[0] == -1.7
322+
assert pumps.lower_stop_level[17] == -1.9
323+
assert np.isnan(pumps.upper_stop_level[14])
324+
assert pumps.display_name[9] == "KGM-JL-18"
335325

336326

337327
def test_get_culverts(db):
@@ -352,8 +342,6 @@ def test_get_culverts(db):
352342
assert culverts.connection_node_start_id[45] == 1220
353343
assert culverts.connection_node_end_id[61] == 1620
354344
assert culverts.calculation_type[4] == CalculationType.ISOLATED
355-
# TODO: fix
356-
# assert culverts.cross_section_definition_id[0] == 97
357345
assert culverts.invert_level_start_point[21] == -2.39
358346
assert culverts.invert_level_end_point[83] == -3.28
359347
assert culverts.discharge_coefficient_negative[0] == 0.8
@@ -384,8 +372,6 @@ def test_get_weirs(db):
384372
assert weirs.connection_node_end_id[7] == 394
385373
assert weirs.crest_level[26] == -2.508
386374
assert weirs.crest_type[0] == CalculationType.SHORT_CRESTED
387-
# TODO: fix this
388-
# assert weirs.cross_section_definition_id[0] == 8
389375
assert weirs.discharge_coefficient_negative[0] == 0.0
390376
assert weirs.discharge_coefficient_positive[0] == 0.8
391377
assert weirs.friction_type[28] == FrictionType.MANNING

0 commit comments

Comments
 (0)