|
1 | 1 | import pytest |
| 2 | +import datetime |
2 | 3 | from os.path import * |
3 | 4 | from odm2api.ODMconnection import dbconnection |
4 | 5 | from odm2api.ODM2.services.createService import CreateODM2 |
5 | | - |
6 | 6 | # run this test from the root directory using: |
7 | 7 | # python -m pytest tests/test_odm2/test_createservice.py |
8 | 8 |
|
@@ -134,4 +134,29 @@ def test_createRelatedModel(self): |
134 | 134 |
|
135 | 135 |
|
136 | 136 | 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