Closed Elijahwalkerwest closed 6 years ago
@Elijahwalkerwest Please fix the test also. I won't merge until we have passing Travis CI. Thanks. Let me know if you need my help.
=================================== FAILURES ===================================
_______________ TestReadService.test_getSamplingFeatureDataSets ________________
self = <tests.test_odm2.test_readservice.TestReadService instance at 0x7fd087c41170>
def test_getSamplingFeatureDataSets(self):
try:
#find a sampling feature that is associated with a dataset
sf = self.engine.execute(
'SELECT * from SamplingFeatures as sf '
'inner join FeatureActions as fa on fa.SamplingFeatureID == sf.SamplingFeatureID '
'inner join Results as r on fa.FeatureActionID == r.FeatureActionID '
'inner join DataSetsResults as ds on r.ResultID == ds.ResultID '
).fetchone()
assert len(sf) > 0
#get the dataset associated with the sampling feature
ds = self.engine.execute(
'SELECT * from DataSetsResults as ds '
'inner join Results as r on r.ResultID == ds.ResultID '
'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID '
'where fa.SamplingFeatureID = ' + str(sf[0])
).fetchone()
assert len(ds) > 0
print (sf[0])
# get the dataset associated with the sampling feature using hte api
dsapi = self.reader.getSamplingFeatureDatasets(ids=[sf[0]])
assert dsapi is not None
assert len(dsapi) > 0
assert dsapi[0].datasets is not None
assert dsapi[0].SamplingFeatureID == sf[0]
# assert ds[0] == dsapi[0]
except Exception as ex:
> assert False
E assert False
tests/test_odm2/test_readservice.py:162: AssertionError
----------------------------- Captured stdout call -----------------------------
1
Error running Query: 'NoneType' object is not iterable
=============== 1 failed, 57 passed, 34 skipped in 4.79 seconds ================
@Elijahwalkerwest What is the status of this?
Seems like the failure reported on https://github.com/ODM2/ODM2PythonAPI/pull/131#issuecomment-350378335 wasn't because the test needed to be changed, but the actual getSamplingFeatureDatasets
function. It didn't have a way to handle SamplingFeatures with either no dataset or related feature.
I've tested the behavior of these changes. They all look good. Thanks @Elijahwalkerwest. Merging now. This resolves #130.
Additionally added ability to filter by SamplingFeatureTypeCV as per Mauriel's request.