Skip to content

Commit 2c51116

Browse files
committed
[#23] added a unit test for create simulation
1 parent 6b2d785 commit 2c51116

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

tests/test_odm2/test_createservice.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
2+
import datetime
23
from os.path import *
34
from odm2api.ODMconnection import dbconnection
45
from odm2api.ODM2.services.createService import CreateODM2
5-
66
# run this test from the root directory using:
77
# python -m pytest tests/test_odm2/test_createservice.py
88

@@ -134,4 +134,29 @@ def test_createRelatedModel(self):
134134

135135

136136
def test_createSimulation(self):
137-
pass
137+
138+
# todo: insert should fail if unitID or actionID do not exist
139+
140+
# assert that there are no datasets in the database
141+
res = self.engine.execute('SELECT * from Simulations')
142+
assert(len(res.fetchall()) == 0)
143+
144+
# create a new simulation
145+
st = datetime.datetime(2016,1,1)
146+
et = datetime.datetime(2016,1,25)
147+
dataset = self.writer.createSimulation( actionid = 1,
148+
modelID=1,
149+
simulationName= 'MySimulation',
150+
simulationDescription = 'My simulation description',
151+
simulationStartDateTime = st,
152+
simulationStartOffset = 6,
153+
simulationEndDateTime = et,
154+
simulationEndOffset = 6,
155+
timeStepValue = 1,
156+
timeStepUnitID = 1,
157+
inputDatasetID=None)
158+
159+
# assert that this record has been successfully inserted
160+
res = self.engine.execute('SELECT * from Simulations')
161+
assert(len(res.fetchall()) == 1)
162+

0 commit comments

Comments
 (0)