File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -964,7 +964,11 @@ def getRelatedModelsByCode(self, modelcode):
964964
965965 def getResultsBySimulationID (self , simulationID ):
966966 try :
967- return self ._session .query (Results ).filter (Simulations .SimulationID == simulationID ).all ()
967+ return self ._session .query (Results ) \
968+ .join (FeatureActions ) \
969+ .join (Actions ) \
970+ .join (Simulations ) \
971+ .filter (Simulations .SimulationID == simulationID ).all ()
968972 except Exception , e :
969973 print e
970974 return None
Original file line number Diff line number Diff line change @@ -214,18 +214,21 @@ def test_getResultsBySimulationID(self):
214214 res = self .engine .execute ('SELECT * FROM Simulations' ).fetchone ()
215215 simulation = rawSql2Alchemy (res , models .Simulations )
216216
217+ # get the results id associated with the simulation
218+ res = self .engine .execute ('SELECT * from Results as r ' \
219+ 'inner join FeatureActions as fa on fa.FeatureActionID == r.FeatureActionID ' \
220+ 'inner join Actions as a on a.ActionID == fa.ActionID ' \
221+ 'inner join Simulations as s on s.ActionID == a.ActionID ' \
222+ 'where s.SimulationID = 1' ).first ()
223+ assert len (res ) > 0
224+ res = rawSql2Alchemy (res , models .Results )
225+ print res
226+
217227 # get simulation by id using the api
218228 resapi = self .reader .getResultsBySimulationID (simulation .SimulationID )
219229 assert resapi is not None
220230 assert len (resapi ) > 0
231+ assert res .ResultID == resapi [0 ].ResultID
221232
222- # test simulation id that doesnt exist
223- resapi = self .reader .getResultsBySimulationID (10 )
224- assert resapi is not None
225- assert len (resapi ) == 0
226-
227- # test invalid argument
228- resapi = self .reader .getResultsBySimulationID (models .ActionBy )
229- assert resapi is None
230233
231234
You can’t perform that action at this time.
0 commit comments