Skip to content

Conversation

@Elijahwalkerwest
Copy link
Contributor

Additionally added ability to filter by SamplingFeatureTypeCV as per Mauriel's request.

@lsetiawan
Copy link
Member

@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 ================

@lsetiawan
Copy link
Member

@Elijahwalkerwest What is the status of this?



def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=None):
def getSamplingFeatureDatasets(self, ids=None, codes=None, uuids=None, dstype=None, type=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type is a reserved python word. Please use sftype to be clear, and avoid using reserved word.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the doc string doesn't seem to reflect this additional argument. Please add.


def assignRelatedFeatures(self, relatedfeatures):
self.related_features = {}
if relatedfeatures:
Copy link
Member

@lsetiawan lsetiawan Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this line to handle cases that there are no relatedfeatures.

# res.FeatureActionObj = None
self.datasets[dsr.DataSetObj].append(res)
self.datasets = {}
if datasetresults:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this line to handle cases that there are no datasets associated.

@lsetiawan
Copy link
Member

Seems like the failure reported on #131 (comment) 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.

Copy link
Member

@lsetiawan lsetiawan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to merge now, once the Travis CI checks are complete.

@lsetiawan
Copy link
Member

I've tested the behavior of these changes. They all look good. Thanks @Elijahwalkerwest. Merging now. This resolves #130.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants