diff --git a/.cache/v/cache/lastfailed b/.cache/v/cache/lastfailed index 91b5cbe..112ca39 100644 --- a/.cache/v/cache/lastfailed +++ b/.cache/v/cache/lastfailed @@ -1,62 +1,16 @@ { - "tests/test_SessionFactory.py::test_aSessionFactory[setup0]": true, - "tests/test_SessionFactory.py::test_aSessionFactory[setup1]": true, - "tests/test_SessionFactory.py::test_aSessionFactory[setup2]": true, - "tests/test_SessionFactory.py::test_aSessionFactory[setup3]": true, "tests/test_SessionFactory.py::test_aSessionFactory[setup4]": true, "tests/test_SessionFactory.py::test_aSessionFactory[setup5]": true, "tests/test_SessionFactory.py::test_aSessionFactory[setup6]": true, - "tests/test_connection.py::test_connection[setup0]": true, - "tests/test_connection.py::test_connection[setup1]": true, "tests/test_connection.py::test_connection[setup2]": true, "tests/test_connection.py::test_connection[setup3]": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createAction": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createActionBy": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createAffiliation": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createDataset": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createDatasetResults": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createDeploymentAction": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createFeatureAction": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createMethod": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createModel": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createOrganization": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createPerson": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createProcessingLevel": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createRelatedModel": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createSamplingFeature": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createSimulation": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createSite": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createSpatialReference": true, "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createTimeSeriesResult": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createTimeSeriesResultValues": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createUnit": true, - "tests/test_odm2/test_createservice.py::TestCreateService::()::test_createVariable": true, - "tests/test_odm2/test_model.py::test_cvelevationdatum[setup0]": true, - "tests/test_odm2/test_model.py::test_cvelevationdatum[setup1]": true, "tests/test_odm2/test_model.py::test_cvelevationdatum[setup2]": true, "tests/test_odm2/test_model.py::test_cvelevationdatum[setup3]": true, - "tests/test_odm2/test_model.py::test_cvsamplingfeatuergeotype[setup0]": true, - "tests/test_odm2/test_model.py::test_cvsamplingfeatuergeotype[setup1]": true, "tests/test_odm2/test_model.py::test_cvsamplingfeatuergeotype[setup2]": true, "tests/test_odm2/test_model.py::test_cvsamplingfeatuergeotype[setup3]": true, - "tests/test_odm2/test_model.py::test_cvsamplingfeaturetype[setup0]": true, - "tests/test_odm2/test_model.py::test_cvsamplingfeaturetype[setup1]": true, "tests/test_odm2/test_model.py::test_cvsamplingfeaturetype[setup2]": true, "tests/test_odm2/test_model.py::test_cvsamplingfeaturetype[setup3]": true, - "tests/test_odm2/test_model.py::test_sampling_feature[setup0]": true, - "tests/test_odm2/test_model.py::test_sampling_feature[setup1]": true, "tests/test_odm2/test_model.py::test_sampling_feature[setup2]": true, - "tests/test_odm2/test_model.py::test_sampling_feature[setup3]": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getAllModels": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getAllResults": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getAllSamplingFeatures": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getAllSimulations": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getModelByCode": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getRelatedModelsByCode": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getRelatedModelsByID": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getResultsByID": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getResultsBySimulationID": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getSamplingFeatureByID": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getSimulationByActionID": true, - "tests/test_odm2/test_readservice.py::TestReadService::()::test_getSimulationByName": true + "tests/test_odm2/test_model.py::test_sampling_feature[setup3]": true } \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index f04a055..b34a56c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ environment: POSTGRES_ENV_POSTGRES_USER: postgres POSTGRES_ENV_POSTGRES_PASSWORD: Password12! POSTGRES_ENV_POSTGRES_DB: odm2 - POSTGRES_PATH: C:\Program Files\PostgreSQL\9.4 + POSTGRES_PATH: C:\Program Files\PostgreSQL\9.5 PGUSER: postgres PGPASSWORD: Password12! @@ -27,7 +27,7 @@ environment: MYSQL_ENV_MYSQL_USER: root MYSQL_ENV_MYSQL_PASSWORD: Password12! MYSQL_ENV_MYSQL_DATABASE: odm2 - MYSQL_PATH: C:\Program Files\MySql\MySQL Server 5.6 + MYSQL_PATH: C:\Program Files\MySql\MySQL Server 5.7 MYSQL_PWD: Password12! # sql server diff --git a/odm2api/ODM2/models.py b/odm2api/ODM2/models.py index 32e69ae..ef66405 100644 --- a/odm2api/ODM2/models.py +++ b/odm2api/ODM2/models.py @@ -889,6 +889,10 @@ class Simulations(Base): Model = relationship(Models) Unit = relationship(Units) + def __repr__(self): + return "" % \ + (self.SimulationID, self.ActionID, self.SimulationName, self.SimulationStartDateTime) + # Part of the Provenance table, needed here to meet dependancies class Citations(Base): @@ -1650,9 +1654,10 @@ class TimeSeriesResults(Results): __mapper_args__ = {'polymorphic_identity':'Time series coverage'} def __repr__(self): - return "" % \ - (self.ResultID, self.XLocation, self.YLocation, self.XLocation, - self.ResultTypeCV, self.XLocationUnitsObj, self.SpatialReferenceObj, + return "" % \ + ( self.FeatureActionID, self.ProcessingLevelID, self.VariableID, self.ProcessinglevelID, + self.self.XLocation, self.YLocation, + self.ResultTypeCV, self.IntendedTimeSpacing, self.AggregationStatisticCV) diff --git a/odm2api/ODM2/services/createService.py b/odm2api/ODM2/services/createService.py index d9360ca..a882ef9 100644 --- a/odm2api/ODM2/services/createService.py +++ b/odm2api/ODM2/services/createService.py @@ -46,6 +46,7 @@ def createProcessingLevel(self, proclevel): return proclevel + #send in any type of sampling feature def createSamplingFeature(self, samplingfeature): self._session.add(samplingfeature) self._session.commit() @@ -97,12 +98,18 @@ def createActionby(self, actionby): self._session.commit() return actionby + def createFeatureAction(self, action): + self._session.add(action) + self._session.commit() + return action + def createRelatedAction(self, relatedaction): self._session.add(relatedaction) self._session.commit() return relatedaction + #send in any type of result object def createResult(self, result): self._session.add(result) self._session.commit() diff --git a/odm2api/ODMconnection.py b/odm2api/ODMconnection.py index c13b115..767cc55 100644 --- a/odm2api/ODMconnection.py +++ b/odm2api/ODMconnection.py @@ -51,20 +51,20 @@ def __init__(self, debug=False): @classmethod def createConnection(self, engine, address, db=None, user=None, password=None, dbtype = 2.0, echo=False): - # if engine == 'sqlite': - # connection_string = engine +':///'+address - # s = SessionFactory(connection_string, echo = echo, version= dbtype) - # setSchema(s.engine) - # return s - # - # else: - connection_string = dbconnection.buildConnDict(dbconnection(), engine, address, db, user, password) - if self.isValidConnection(connection_string, dbtype): - s= SessionFactory(connection_string, echo = echo, version= dbtype) + if engine == 'sqlite': + connection_string = engine +':///'+address + s = SessionFactory(connection_string, echo = echo, version= dbtype) setSchema(s.engine) return s - else : - return None + + else: + connection_string = dbconnection.buildConnDict(dbconnection(), engine, address, db, user, password) + if self.isValidConnection(connection_string, dbtype): + s= SessionFactory(connection_string, echo = echo, version= dbtype) + setSchema(s.engine) + return s + else : + return None # if self.testConnection(connection_string): @classmethod diff --git a/tests/test_odm2/test_createservice.py b/tests/test_odm2/test_createservice.py index 5fe1cfe..f9aa5bb 100644 --- a/tests/test_odm2/test_createservice.py +++ b/tests/test_odm2/test_createservice.py @@ -171,13 +171,14 @@ def test_createDataset(self): d = models.DataSets(DataSetTypeCV = type, DataSetCode =code, DataSetTitle=title, DataSetAbstract = desc, DataSetUUID = uuid.uuid4().hex) dataset = self.writer.createDataset(d) - + assert(dataset == d) + assert (dataset.DataSetID ==1) # assert that this dataset has been successfully inserted res = self.engine.execute('SELECT * from DataSets').fetchall() assert(len(res) == 1) - assert(res[0]==dataset.DataSetID) + assert(res[0][0]==dataset.DataSetID) def test_createDatasetResults(self): pass @@ -246,21 +247,27 @@ def test_createTimeSeriesResult(self): ValueCount = 0, SampledMediumCV = 'unknown', ResultTypeCV = 'time series', - ResultUUID = uuid.uuid4().hex, + ResultUUID = str(uuid.uuid4()), AggregationStatisticCV = 'unknown' + ) - ) newres=self.writer.createResult(r) + + # assert that this basic tsr exists in the database + tsr = self.engine.execute('SELECT * FROM TimeSeriesResults').first() + assert(tsr is not None) + + assert (newres == r) result = self.engine.execute('SELECT * FROM Results').first() assert(result is not None) + + assert(newres.ResultID ==1) assert(result[0] ==newres.ResultID) - # assert that this basic tsr exists in the database - res = self.engine.execute('SELECT * FROM TimeSeriesResults').first() - assert(res is not None) + @@ -322,9 +329,10 @@ def test_createSimulation(self): ModelID = 1 ) sim = self.writer.createSimulation(s) - + assert (s == sim) + assert (s.SimulationID == 1) # assert that this record has been successfully inserted res = self.engine.execute('SELECT * from Simulations').fetchall() assert(len(res) == 1) - assert(res[0]==sim.SimulationID) + assert(res[0][0]==s.SimulationID)