11
11
import sqlalchemy
12
12
from sqlalchemy .orm import class_mapper
13
13
14
-
15
14
globals_vars = {}
16
15
17
16
@@ -75,7 +74,6 @@ def setup(self):
75
74
self .engine = globals_vars ['engine' ]
76
75
self .db = globals_vars ['db' ]
77
76
78
-
79
77
# Sampling Features
80
78
def test_getAllSamplingFeatures (self ):
81
79
# get all models from the database
@@ -91,7 +89,7 @@ def test_getSamplingFeatureByID(self):
91
89
# get all simulations using the api
92
90
resapi = self .reader .getSamplingFeatures (ids = [sfid ])
93
91
assert resapi is not None
94
-
92
+
95
93
def test_getSamplingFeatureByCode (self ):
96
94
# get all models from the database
97
95
res = self .engine .execute ('SELECT * FROM SamplingFeatures' ).fetchone ()
@@ -100,7 +98,7 @@ def test_getSamplingFeatureByCode(self):
100
98
resapi = self .reader .getSamplingFeatures (codes = [code ])
101
99
assert resapi is not None
102
100
103
- # DataSets
101
+ # DataSets
104
102
def test_getDataSets (self ):
105
103
# get all datasets from the database
106
104
ds = self .engine .execute ('SELECT * FROM DataSets' ).fetchone ()
@@ -124,14 +122,13 @@ def test_getDataSetsValues(self):
124
122
dsr = self .engine .execute ('SELECT * FROM DataSetsResults' ).fetchone ()
125
123
dsid = dsr [2 ]
126
124
127
- values = self .reader .getDataSetsValues (ids = [dsid ])
125
+ values = self .reader .getDataSetsValues (ids = [dsid ])
128
126
assert values is not None
129
127
assert len (values ) > 0
130
128
131
-
132
129
def test_getSamplingFeatureDataSets (self ):
133
130
try :
134
- #find a sampling feature that is associated with a dataset
131
+ # find a sampling feature that is associated with a dataset
135
132
sf = self .engine .execute (
136
133
'SELECT * from SamplingFeatures as sf '
137
134
'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID '
@@ -140,7 +137,7 @@ def test_getSamplingFeatureDataSets(self):
140
137
).fetchone ()
141
138
assert len (sf ) > 0
142
139
143
- #get the dataset associated with the sampling feature
140
+ # get the dataset associated with the sampling feature
144
141
ds = self .engine .execute (
145
142
'SELECT * from DataSetsResults as ds '
146
143
'inner join Results as r on r.ResultID == ds.ResultID '
@@ -149,7 +146,7 @@ def test_getSamplingFeatureDataSets(self):
149
146
).fetchone ()
150
147
assert len (ds ) > 0
151
148
152
- print (sf [0 ])
149
+ print (sf [0 ])
153
150
# get the dataset associated with the sampling feature using hte api
154
151
dsapi = self .reader .getSamplingFeatureDatasets (ids = [sf [0 ]])
155
152
@@ -159,11 +156,11 @@ def test_getSamplingFeatureDataSets(self):
159
156
assert dsapi [0 ].SamplingFeatureID == sf [0 ]
160
157
# assert ds[0] == dsapi[0]
161
158
except Exception as ex :
159
+ print (ex )
162
160
assert False
163
161
finally :
164
162
self .reader ._session .rollback ()
165
163
166
-
167
164
# Results
168
165
def test_getAllResults (self ):
169
166
@@ -174,7 +171,6 @@ def test_getAllResults(self):
174
171
resapi = self .reader .getResults ()
175
172
assert len (res ) == len (resapi )
176
173
177
-
178
174
def test_getResultsByID (self ):
179
175
# get a result from the database
180
176
res = self .engine .execute ('SELECT * FROM Results' ).fetchone ()
@@ -186,18 +182,18 @@ def test_getResultsByID(self):
186
182
187
183
def test_getResultsBySFID (self ):
188
184
sf = self .engine .execute (
189
- 'SELECT * from SamplingFeatures as sf '
190
- 'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID '
191
- 'inner join Results as r on fa.FeatureActionID == r.FeatureActionID '
192
- ).fetchone ()
185
+ 'SELECT * from SamplingFeatures as sf '
186
+ 'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID '
187
+ 'inner join Results as r on fa.FeatureActionID == r.FeatureActionID '
188
+ ).fetchone ()
193
189
assert len (sf ) > 0
194
190
sfid = sf [0 ]
195
191
196
192
res = self .engine .execute (
197
- 'SELECT * from Results as r '
198
- 'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID '
199
- 'where fa.SamplingFeatureID = ' + str (sfid )
200
- ).fetchone ()
193
+ 'SELECT * from Results as r '
194
+ 'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID '
195
+ 'where fa.SamplingFeatureID = ' + str (sfid )
196
+ ).fetchone ()
201
197
202
198
assert len (res ) > 0
203
199
@@ -223,7 +219,6 @@ def test_getModelByCode(self):
223
219
resapi = self .reader .getModels (codes = [modelCode ])
224
220
assert resapi is not None
225
221
226
-
227
222
# RelatedModels
228
223
def test_getRelatedModelsByID (self ):
229
224
# get related models by id using the api
@@ -247,7 +242,8 @@ def test_getRelatedModelsByCode(self):
247
242
# test invalid argument
248
243
resapi = self .reader .getRelatedModels (code = 234123 )
249
244
assert not resapi
250
- # Simulations
245
+
246
+ # Simulations
251
247
def test_getAllSimulations (self ):
252
248
# get all simulation from the database
253
249
res = self .engine .execute ('SELECT * FROM Simulations' ).fetchall ()
0 commit comments