Skip to content

Commit

Permalink
test msx options
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed May 8, 2024
1 parent d2fc91f commit 449f5b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,100 +1,103 @@
from epyt import epanet
from epyt import epanet, networks
import unittest
import os

DIRNAME = os.path.dirname(networks.__file__)


class MSXtest(unittest.TestCase):

def setUp(self):
"""Call before every test case."""
# Create EPANET object using the INP file
inpname = os.path.join(os.getcwd(), 'epyt', 'networks', 'msx-examples', 'net2-cl2.inp')
msxname = os.path.join(os.getcwd(), 'epyt', 'networks', 'msx-examples', 'net2-cl2.msx')
inpname = os.path.join(DIRNAME, 'msx-examples', 'net2-cl2.inp')
msxname = os.path.join(DIRNAME, 'msx-examples', 'net2-cl2.msx')
self.epanetClass = epanet(inpname)
self.msxClass = self.epanetClass.loadMSXFile(msxname)

def tearDown(self):
"""Call after every test case."""
self.msxClass.MSXclose()
self.epanetClass.unloadMSX()
self.epanetClass.unload()

""" ------------------------------------------------------------------------- """
#new functions - Read MSX file

# new functions - Read MSX file
def test_MSXOptions(self):
self.assertEqual(self.epanetClass.getMSXTimeStep(),
(300), 'Wrong get timestep comment output')
300, 'Wrong get timestep comment output')

self.epanetClass.setMSXTimeStep(4200)
self.assertEqual(self.epanetClass.getMSXTimeStep(),
(4200), 'Wrong get timestep comment output')
4200, 'Wrong get timestep comment output')

self.assertEqual(self.epanetClass.getMSXAreaUnits(),
("FT2"), 'Wrong get Area Units comment output')
"FT2", 'Wrong get Area Units comment output')

self.epanetClass.setMSXAreaUnitsFT2()
self.assertEqual(self.epanetClass.getMSXAreaUnits(),
("FT2"), 'Wrong get Area Units comment output')
"FT2", 'Wrong get Area Units comment output')
self.epanetClass.setMSXAreaUnitsM2()
self.assertEqual(self.epanetClass.getMSXAreaUnits(),
("M2"), 'Wrong get Area Units comment output')
"M2", 'Wrong get Area Units comment output')
self.epanetClass.setMSXAreaUnitsCM2()
self.assertEqual(self.epanetClass.getMSXAreaUnits(),
("CM2"), 'Wrong get Area Units comment output')
"CM2", 'Wrong get Area Units comment output')

self.epanetClass.setMSXRateUnitsSEC()
self.assertEqual(self.epanetClass.getMSXRateUnits(),
("SEC"),"Wrong get Rate Units coments output")
"SEC", "Wrong get Rate Units comments output")
self.epanetClass.setMSXRateUnitsMIN()
self.assertEqual(self.epanetClass.getMSXRateUnits(),
("MIN"), "Wrong get Rate Units coments output")
"MIN", "Wrong get Rate Units comments output")
self.epanetClass.setMSXRateUnitsDAY()
self.assertEqual(self.epanetClass.getMSXRateUnits(),
("DAY"), "Wrong get Rate Units coments output")
"DAY", "Wrong get Rate Units comments output")

self.epanetClass.setMSXSolverEUL()
self.assertEqual(self.epanetClass.getMSXSolver(),
("EUL"), "Wrong get Solver coments output")
"EUL", "Wrong get Solver comments output")

self.epanetClass.setMSXSolverRK5()
self.assertEqual(self.epanetClass.getMSXSolver(),
("RK5"), "Wrong get Solver coments output")
"RK5", "Wrong get Solver comments output")
self.epanetClass.setMSXSolverROS2()
self.assertEqual(self.epanetClass.getMSXSolver(),
("ROS2"), "Wrong get Solver coments output")
"ROS2", "Wrong get Solver comments output")

self.epanetClass.setMSXCouplingFULL()
self.assertEqual(self.epanetClass.getMSXCoupling(),
("FULL"), "Wrong get Coupling coments output")
"FULL", "Wrong get Coupling comments output")
self.epanetClass.setMSXCouplingNONE()
self.assertEqual(self.epanetClass.getMSXCoupling(),
("NONE"), "Wrong get Coupling coments output")
"NONE", "Wrong get Coupling comments output")

self.epanetClass.setMSXCompilerVC()
self.assertEqual(self.epanetClass.getMSXCompiler(),
("VC"), "Wrong get Compiler coments output")
"VC", "Wrong get Compiler comments output")
self.epanetClass.setMSXCompilerGC()
self.assertEqual(self.epanetClass.getMSXCompiler(),
("GC"), "Wrong get Compiler coments output")
"GC", "Wrong get Compiler comments output")
self.epanetClass.setMSXCompilerNONE()
self.assertEqual(self.epanetClass.getMSXCompiler(),
("NONE"), "Wrong get Compiler coments output")
"NONE", "Wrong get Compiler comments output")

self.epanetClass.setMSXAtol(0.2)
self.assertEqual(self.epanetClass.getMSXAtol(),
(0.2), "Wrong get ATOL coments output")
0.2, "Wrong get ATOL comments output")
self.epanetClass.setMSXRtol(0.2)
self.assertEqual(self.epanetClass.getMSXRtol(),
(0.2), "Wrong get RTOL coments output")

0.2, "Wrong get RTOL comments output")

def test_Parameters(self):
self.assertEqual(self.epanetClass.getMSXEquationsTerms(),
(["Kf 1.5826e-4 * RE^0.88 / D"]), 'Wrong get Equations comment output')
self.assertEqual(self.epanetClass.getMSXEquationsPipes(),
(["RATE CL2 -Kb*CL2 - (4/D)*Kw*Kf/(Kw+Kf)*CL2"]), 'Wrong get Equations comment output')
(["RATE CL2 -Kb*CL2 - (4/D)*Kw*Kf/(Kw+Kf)*CL2"]),
'Wrong get Equations comment output')
self.assertEqual(self.epanetClass.getMSXEquationsTanks(),
(["RATE CL2 -Kb*CL2"]), 'Wrong get Equations comment output')


if __name__ == "__main__":
unittest.main()
unittest.main()

0 comments on commit 449f5b7

Please sign in to comment.