@@ -63,8 +63,10 @@ def test_createVariable(self):
6363 nodv = - 9999
6464 speciation = "mg/L as PO4"
6565 definition = "This is a test variable"
66- self .writer .createVariable (code = code ,name = name ,vType = vType ,nodv = nodv ,speciation = None ,definition = None )
67-
66+ v = models .Variables (VariableCode = code , VariableName = name , VariableTypeCV = vType , NoDataValue = nodv , Speciation = speciation ,
67+ Definition = definition )
68+ # self.writer.createVariable(code = code,name = name,vType = vType,nodv =nodv,speciation=None,definition=None)
69+ self .writer .createVariable (v )
6870 # assert that this dataset has been successfully inserted
6971 res = self .engine .execute ('SELECT * from Variables WHERE VariableCode = "MyVar" ORDER BY VariableID DESC' ).first ()
7072 assert (res is not None )
@@ -75,7 +77,10 @@ def test_createVariable(self):
7577 assert (res [5 ] == None ) # speciation
7678 assert (res [6 ] == nodv ) # nodata
7779
78- self .writer .createVariable (code = code , name = name , vType = vType , nodv = nodv , speciation = speciation ,definition = None )
80+ v = models .Variables (VariableCode = code , VariableName = name , VariableTypeCV = vType , NoDataValue = nodv , Speciation = speciation ,
81+ Definition = definition )
82+ # self.writer.createVariable(code = code,name = name,vType = vType,nodv =nodv,speciation=None,definition=None)
83+ self .writer .createVariable (v )
7984
8085 # assert that this dataset has been successfully inserted
8186 res = self .engine .execute ('SELECT * from Variables WHERE VariableCode = "MyVar" ORDER BY VariableID DESC' ).first ()
@@ -87,8 +92,11 @@ def test_createVariable(self):
8792 assert (res [5 ] == speciation ) # speciation
8893 assert (res [6 ] == nodv ) # nodata
8994
95+ v = models .Variables (VariableCode = code , VariableName = name , VariableTypeCV = vType , NoDataValue = nodv , Speciation = speciation ,
96+ Definition = definition )
97+ # self.writer.createVariable(code = code,name = name,vType = vType,nodv =nodv,speciation=None,definition=None)
98+ self .writer .createVariable (v )
9099
91- self .writer .createVariable (code = code ,name = name ,vType = vType ,nodv = nodv ,speciation = None ,definition = definition )
92100
93101 # assert that this dataset has been successfully inserted
94102 res = self .engine .execute ('SELECT * from Variables WHERE VariableCode = "MyVar" ORDER BY VariableID DESC' ).first ()
@@ -101,7 +109,11 @@ def test_createVariable(self):
101109 assert (res [6 ] == nodv ) # nodata
102110
103111
104- self .writer .createVariable (code = code ,name = name ,vType = vType ,nodv = nodv ,speciation = speciation ,definition = definition )
112+ v = models .Variables (VariableCode = code , VariableName = name , VariableTypeCV = vType , NoDataValue = nodv , Speciation = speciation ,
113+ Definition = definition )
114+ # self.writer.createVariable(code = code,name = name,vType = vType,nodv =nodv,speciation=None,definition=None)
115+ self .writer .createVariable (v )
116+
105117
106118 # assert that this dataset has been successfully inserted
107119 res = self .engine .execute ('SELECT * from Variables WHERE VariableCode = "MyVar" ORDER BY VariableID DESC' ).first ()
@@ -147,10 +159,14 @@ def test_createDataset(self):
147159 assert (len (res .fetchall ()) == 0 )
148160
149161 # create a new dataset
150- dataset = self .writer .createDataset (dstype = type ,
151- dscode = code ,
152- dstitle = title ,
153- dsabstract = desc )
162+ # dataset = self.writer.createDataset(dstype=type,
163+ # dscode=code,
164+ # dstitle=title,
165+ # dsabstract=desc)
166+ #TODO uuid
167+ d = models .Datasets (DataSetTypeCV = type , DataSetCode = code , DataSetTitle = title , DataSetAbstract = desc )
168+ dataset = self .writer .createDataset (d )
169+
154170
155171 # assert that this dataset has been successfully inserted
156172 res = self .engine .execute ('SELECT * from DataSets' )
@@ -176,15 +192,31 @@ def test_createResult(self):
176192 assert (len (res .fetchall ()) == 0 )
177193
178194 # create a result record
179- self .writer .createResult (featureactionid = 1 ,
180- variableid = 1 ,
181- unitid = 1 ,
182- processinglevelid = 1 ,
183- valuecount = 0 ,
184- sampledmedium = 'unknown' ,
185- resulttypecv = 'time series' ,
186- taxonomicclass = None , resultdatetime = None , resultdatetimeutcoffset = None ,
187- validdatetime = None , validdatetimeutcoffset = None , statuscv = None )
195+ # self.writer.createResult(featureactionid = 1,
196+ # variableid = 1,
197+ # unitid = 1,
198+ # processinglevelid = 1,
199+ # valuecount = 0,
200+ # sampledmedium = 'unknown',
201+ # resulttypecv = 'time series',
202+ # taxonomicclass=None, resultdatetime=None, resultdatetimeutcoffset=None,
203+ # validdatetime=None, validdatetimeutcoffset=None, statuscv=None)
204+ #TODO uuid
205+ r = models .Results (FeatureActionID = 1 ,
206+ VariableID = 1 ,
207+ UnitsID = 1 ,
208+ ProcessingLevelID = 1 ,
209+ ValueCount = 0 ,
210+ SampledMediumCV = 'unknown' ,
211+ ResultTypeCV = 'time series' ,
212+ TaxonomicClassifierID = None ,
213+ ResultDateTime = None ,
214+ ResultDateTimeUTCOffset = None ,
215+ ValidDateTime = None ,
216+ ValidDateTimeUTCOffset = None ,
217+ StatusCV = None
218+ )
219+ self .writer .createResult (r )
188220
189221
190222 # assert that there are results
@@ -201,15 +233,27 @@ def test_createTimeSeriesResult(self):
201233 result = self .engine .execute ('SELECT * FROM Results' ).first ()
202234 if result is None :
203235 # create a basic result record
204- self .writer .createResult (featureactionid = 1 ,variableid = 1 ,unitid = 1 ,processinglevelid = 1 ,
205- valuecount = 0 ,sampledmedium = 'unknown' ,resulttypecv = 'time series' )
236+ # self.writer.createResult(featureactionid = 1,variableid = 1,unitid = 1,processinglevelid = 1,
237+ # valuecount = 0,sampledmedium = 'unknown',resulttypecv = 'time series')
238+ #TODO uuid
239+ r = models .Results (FeatureActionID = 1 ,
240+ VariableID = 1 ,
241+ UnitsID = 1 ,
242+ ProcessingLevelID = 1 ,
243+ ValueCount = 0 ,
244+ SampledMediumCV = 'unknown' ,
245+ ResultTypeCV = 'time series' ,
246+
247+ )
248+ self .writer .createResult (r )
206249 result = self .engine .execute ('SELECT * FROM Results' ).first ()
207250 assert (result is not None )
208251
209252
210253 # create most basic time series result record possible
211- tsr = self .writer .createTimeSeriesResult (result = result , aggregationstatistic = 'unknown' )
212-
254+ # tsr = self.writer.createTimeSeriesResult(result=result, aggregationstatistic='unknown')
255+ t = models .TimeSeriesResults (ResultID = result .ResultID , AggregationStatisticCV = 'unknown' )
256+ tsr = self .writer .createResults (t )
213257 # assert that this basic tsr exists in the datbase
214258 res = self .engine .execute ('SELECT * FROM TimeSeriesResults' ).first ()
215259 assert (res is not None )
@@ -250,17 +294,29 @@ def test_createSimulation(self):
250294 # create a new simulation
251295 st = datetime .datetime (2016 ,1 ,1 )
252296 et = datetime .datetime (2016 ,1 ,25 )
253- dataset = self .writer .createSimulation ( actionid = 1 ,
254- modelID = 1 ,
255- simulationName = 'MySimulation' ,
256- simulationDescription = 'My simulation description' ,
257- simulationStartDateTime = st ,
258- simulationStartOffset = 6 ,
259- simulationEndDateTime = et ,
260- simulationEndOffset = 6 ,
261- timeStepValue = 1 ,
262- timeStepUnitID = 1 ,
263- inputDatasetID = None )
297+ # sim = self.writer.createSimulation( actionid = 1,
298+ # modelID=1,
299+ # simulationName= 'MySimulation',
300+ # simulationDescription = 'My simulation description',
301+ # simulationStartDateTime = st,
302+ # simulationStartOffset = 6,
303+ # simulationEndDateTime = et,
304+ # simulationEndOffset = 6,
305+ # timeStepValue = 1,
306+ # timeStepUnitID = 1,
307+ # inputDatasetID=None)
308+ s = models .Simulations (ActionID = 1 ,
309+ SimulationName = "MySimulation" ,
310+ SimulationDescription = "My simulation description" ,
311+ SimulationsStartDateTime = st ,
312+ SimulationStartOffset = 6 ,
313+ SimulationEdnDateTime = et ,
314+ SimulationEndOffset = 6 ,
315+ TimeStepValue = 1 ,
316+ TimeStepuUnitsID = 1 ,
317+ InputDataSetID = None
318+ )
319+ sim = self .writer .creatSimulation (s )
264320
265321 # assert that this record has been successfully inserted
266322 res = self .engine .execute ('SELECT * from Simulations' )
0 commit comments