Skip to content

Commit 7b59e77

Browse files
committed
Clean up tests
1 parent b751673 commit 7b59e77

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

tests/test_connection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from odm2api.ODM2.models import CVElevationDatum
44
from odm2api.ODMconnection import dbconnection
5+
56
import pytest
7+
68
from sqlalchemy.engine import reflection
79

810

tests/test_odm2/test_readservice.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import sqlalchemy
1212
from sqlalchemy.orm import class_mapper
1313

14-
1514
globals_vars = {}
1615

1716

@@ -75,7 +74,6 @@ def setup(self):
7574
self.engine = globals_vars['engine']
7675
self.db = globals_vars['db']
7776

78-
7977
# Sampling Features
8078
def test_getAllSamplingFeatures(self):
8179
# get all models from the database
@@ -91,7 +89,7 @@ def test_getSamplingFeatureByID(self):
9189
# get all simulations using the api
9290
resapi = self.reader.getSamplingFeatures(ids=[sfid])
9391
assert resapi is not None
94-
92+
9593
def test_getSamplingFeatureByCode(self):
9694
# get all models from the database
9795
res = self.engine.execute('SELECT * FROM SamplingFeatures').fetchone()
@@ -100,7 +98,7 @@ def test_getSamplingFeatureByCode(self):
10098
resapi = self.reader.getSamplingFeatures(codes=[code])
10199
assert resapi is not None
102100

103-
#DataSets
101+
# DataSets
104102
def test_getDataSets(self):
105103
# get all datasets from the database
106104
ds = self.engine.execute('SELECT * FROM DataSets').fetchone()
@@ -124,14 +122,13 @@ def test_getDataSetsValues(self):
124122
dsr = self.engine.execute('SELECT * FROM DataSetsResults').fetchone()
125123
dsid = dsr[2]
126124

127-
values= self.reader.getDataSetsValues(ids=[dsid])
125+
values = self.reader.getDataSetsValues(ids=[dsid])
128126
assert values is not None
129127
assert len(values) > 0
130128

131-
132129
def test_getSamplingFeatureDataSets(self):
133130
try:
134-
#find a sampling feature that is associated with a dataset
131+
# find a sampling feature that is associated with a dataset
135132
sf = self.engine.execute(
136133
'SELECT * from SamplingFeatures as sf '
137134
'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID '
@@ -140,7 +137,7 @@ def test_getSamplingFeatureDataSets(self):
140137
).fetchone()
141138
assert len(sf) > 0
142139

143-
#get the dataset associated with the sampling feature
140+
# get the dataset associated with the sampling feature
144141
ds = self.engine.execute(
145142
'SELECT * from DataSetsResults as ds '
146143
'inner join Results as r on r.ResultID == ds.ResultID '
@@ -149,7 +146,7 @@ def test_getSamplingFeatureDataSets(self):
149146
).fetchone()
150147
assert len(ds) > 0
151148

152-
print (sf[0])
149+
print(sf[0])
153150
# get the dataset associated with the sampling feature using hte api
154151
dsapi = self.reader.getSamplingFeatureDatasets(ids=[sf[0]])
155152

@@ -159,11 +156,11 @@ def test_getSamplingFeatureDataSets(self):
159156
assert dsapi[0].SamplingFeatureID == sf[0]
160157
# assert ds[0] == dsapi[0]
161158
except Exception as ex:
159+
print(ex)
162160
assert False
163161
finally:
164162
self.reader._session.rollback()
165163

166-
167164
# Results
168165
def test_getAllResults(self):
169166

@@ -174,7 +171,6 @@ def test_getAllResults(self):
174171
resapi = self.reader.getResults()
175172
assert len(res) == len(resapi)
176173

177-
178174
def test_getResultsByID(self):
179175
# get a result from the database
180176
res = self.engine.execute('SELECT * FROM Results').fetchone()
@@ -186,18 +182,18 @@ def test_getResultsByID(self):
186182

187183
def test_getResultsBySFID(self):
188184
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()
193189
assert len(sf) > 0
194190
sfid = sf[0]
195191

196192
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()
201197

202198
assert len(res) > 0
203199

@@ -223,7 +219,6 @@ def test_getModelByCode(self):
223219
resapi = self.reader.getModels(codes=[modelCode])
224220
assert resapi is not None
225221

226-
227222
# RelatedModels
228223
def test_getRelatedModelsByID(self):
229224
# get related models by id using the api
@@ -247,7 +242,8 @@ def test_getRelatedModelsByCode(self):
247242
# test invalid argument
248243
resapi = self.reader.getRelatedModels(code=234123)
249244
assert not resapi
250-
# Simulations
245+
246+
# Simulations
251247
def test_getAllSimulations(self):
252248
# get all simulation from the database
253249
res = self.engine.execute('SELECT * FROM Simulations').fetchall()

0 commit comments

Comments
 (0)