I have to rewrite some stored procedures so I am writing a test to make sure for every input I am getting the same output.
I have something like
from com.inductiveautomation.common.util import DatasetTestUtils
def testSP():
orig_call = system.db.createSProcCall('orginalSP')
system.db.execSProcCall(orig_call)
new_call = system.db.createSProceCall('newSP')
system.db.execSProcCall(new_call)
orig_data = orig_call.getResultSet()
new_data = new_call.getResultSet()
comparison = DatasetTestUtils.equals(orig_data, new_data)
print str(comparison)
return orig_data, new_data
# another func
def compareDS(ds1, ds2):
pyDs1 = set(tuple(row) for row in system.dataset.toPyDataSet(ds1))
pyDs2 = set(tuple(row) for row in system.dataset.toPyDataSet(ds2))
print 'in original but not new'
print pyDs1 - pyDs2
print 'in new but not original'
print pyDs2 - pyDs1
orig_data, new_data = testSP()
comapreDS(orig_data, new_data)
Print ds1/ds2 shows the same number of rows and columns. str(comparison)
is false but @pturmel forsaw the future before I even finished writing the post so that's explainable.
I copied compareDS
from @JordanCClark and both print statements show me an empty set - it seems like it should work.