from __main__ import default
Unit tests for task viewer. It tests the following parameters:
displaytype: how the image should be displayed
channel: which channel of the cube should be displayed
outdpi: resolution of the output
gui: no gui should be displayed
class viewer_test1(unittest.TestCase):
self.uname = os.uname()[0]
if self.uname == 'Linux' :
self.chksum = '/usr/bin/md5sum'
elif self.uname == 'Darwin' :
self.chksum = '/sbin/md5'
if self.chksum is None or not os.path.exists(self.chksum) :
raise RuntimeError("no md5 checksum program is available")
if (os.path.exists(self.img)):
os.system('rm -rf ' + self.img)
datapath = os.environ.get('CASAPATH').split()[0] + '/data/demo/Images/'
shutil.copytree(datapath+self.img, self.img)
if (os.path.exists(self.img)):
os.system('rm -rf ' + self.img)
def getchecksum(self,img):
if self.uname == 'Linux' :
proc = subprocess.Popen(self.chksum + ' ' + img,stdout=subprocess.PIPE,shell=True)
outstr = repr(proc.communicate()[0]).split()[0]
return outstr.split("'")[1]
elif self.uname == 'Darwin' :
proc = subprocess.Popen(self.chksum + ' ' + img,stdout=subprocess.PIPE,shell=True)
outstr = repr(proc.communicate()[0]).split()
last_element = outstr[len(outstr)-1].split('\\')
'''Viewer 1: create png (default size, channel 0)'''
viewer(infile=self.img,outfile=outfile,gui=False)
self.assertEqual(self.getchecksum(outfile),'e55d704ed0694d59dbf1fb0c01f299f8')