Skip to content

Commit

Permalink
update create functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanie committed Jun 29, 2016
1 parent edb3e0d commit fabd2d7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 73 deletions.
48 changes: 1 addition & 47 deletions .cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions odm2api/ODM2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,10 @@ class Simulations(Base):
Model = relationship(Models)
Unit = relationship(Units)

def __repr__(self):
return "<Simulations('%s', '%s', '%s', '%s')>" % \
(self.SimulationID, self.ActionID, self.SimulationName, self.SimulationStartDateTime)


# Part of the Provenance table, needed here to meet dependancies
class Citations(Base):
Expand Down Expand Up @@ -1650,9 +1654,10 @@ class TimeSeriesResults(Results):
__mapper_args__ = {'polymorphic_identity':'Time series coverage'}

def __repr__(self):
return "<TimeSeriesResults('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')>" % \
(self.ResultID, self.XLocation, self.YLocation, self.XLocation,
self.ResultTypeCV, self.XLocationUnitsObj, self.SpatialReferenceObj,
return "<TimeSeriesResult('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')>" % \
( self.FeatureActionID, self.ProcessingLevelID, self.VariableID, self.ProcessinglevelID,
self.self.XLocation, self.YLocation,
self.ResultTypeCV,
self.IntendedTimeSpacing, self.AggregationStatisticCV)


Expand Down
7 changes: 7 additions & 0 deletions odm2api/ODM2/services/createService.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
24 changes: 12 additions & 12 deletions odm2api/ODMconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions tests/test_odm2/test_createservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)




Expand Down Expand Up @@ -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)

0 comments on commit fabd2d7

Please sign in to comment.