Skip to content

Commit c29e328

Browse files
authored
Merge pull request #15 from michaeltryby/dev
Adding unit test for OutputMetadata
2 parents 03afb6c + fb4586b commit c29e328

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

output/epanet/output/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class OutputMetadata():
105105

106106
def __init__(self, output_handle):
107107

108+
self.units = list()
108109
# If outputhandle not initialized use default settings
109110
if output_handle == None:
110111
self.units = [oapi.FlowUnits.GPM.value,

output/tests/test_output.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,36 @@
55
from epanet.output import OutputMetadata
66
from epanet.output import output as oapi
77

8+
from data import OUTPUT_FILE_EXAMPLE1
89

9-
def test_outputmetadata():
10-
om = OutputMetadata(None)
10+
11+
def test_outputmetadata_handle():
12+
13+
ref = {
14+
oapi.NodeAttribute.DEMAND: ("Demand", "gal/min"),
15+
oapi.NodeAttribute.HEAD: ("Head", "ft"),
16+
oapi.NodeAttribute.PRESSURE: ("Pressure", "psi"),
17+
oapi.NodeAttribute.QUALITY: ("Quality", "mg/L"),
18+
19+
oapi.LinkAttribute.FLOW: ("Flow", "gal/min"),
20+
oapi.LinkAttribute.VELOCITY: ("Velocity", "ft/sec"),
21+
oapi.LinkAttribute.HEADLOSS: ("Unit Headloss", "ft/1000ft"),
22+
oapi.LinkAttribute.AVG_QUALITY: ("Quality", "mg/L"),
23+
oapi.LinkAttribute.STATUS: ("Status", ""),
24+
oapi.LinkAttribute.SETTING: ("Setting", ""),
25+
oapi.LinkAttribute.RX_RATE: ("Reaction Rate", "mg/hr"),
26+
oapi.LinkAttribute.FRCTN_FCTR: ("Friction Factor", "unitless")}
27+
28+
handle = oapi.init()
29+
oapi.open(handle, OUTPUT_FILE_EXAMPLE1)
30+
31+
om = OutputMetadata(handle)
1132

33+
for attr in oapi.NodeAttribute:
34+
temp = om.get_attribute_metadata(attr)
35+
assert temp == ref[attr]
36+
1237
for attr in oapi.LinkAttribute:
1338
temp = om.get_attribute_metadata(attr)
14-
39+
assert temp == ref[attr]
40+

0 commit comments

Comments
 (0)