Beispiel #1
0
 def test02(self):
     """Test 2: Test overwrite=True"""
     tid = "02"
     infile = self.infile2
     outfile = self.outroot+tid+".out"
     result = sdlistold(infile=infile,outfile=outfile)
     self.assertEqual(result,None,
                      msg="The task returned '"+str(result)+"' instead of None")
     self.assertTrue(os.path.exists(outfile),
                     msg="Output file doesn't exist after the 1st run.")
     # overwrite 'outfile'
     infile = self.infile1
     outfile = self.outroot+tid+".out"
     result = sdlistold(infile=infile,outfile=outfile,overwrite=True)
     self.assertEqual(result,None,
                      msg="The task returned '"+str(result)+"' instead of None")
     self._compareOutFile(outfile,self.datapath+self.reffile)
Beispiel #2
0
 def test01(self):
     """Test 1: Save output to an ascii file"""
     tid = "01"
     infile = self.infile1
     outfile = self.outroot+tid+".out"
     result = sdlistold(infile=infile,outfile=outfile)
     self.assertEqual(result,None,
                      msg="The task returned '"+str(result)+"' instead of None")
     self._compareOutFile(outfile,self.datapath+self.reffile)
Beispiel #3
0
 def test01(self):
     """Test 1: Save output to an ascii file"""
     tid = "01"
     infile = self.infile1
     outfile = self.outroot + tid + ".out"
     result = sdlistold(infile=infile, outfile=outfile)
     self.assertEqual(result,
                      None,
                      msg="The task returned '" + str(result) +
                      "' instead of None")
     self._compareOutFile(outfile, self.datapath + self.reffile)
Beispiel #4
0
 def test03(self):
     """Test 3: Test overwrite=False"""
     tid = "03"
     infile = self.infile2
     outfile = self.outroot+tid+".out"
     result = sdlistold(infile=infile,outfile=outfile)
     self.assertEqual(result,None,
                      msg="The task returned '"+str(result)+"' instead of None")
     self.assertTrue(os.path.exists(outfile),
                     msg="Output file doesn't exist after the 1st run.")
     # overwrite 'outfile'
     infile = self.infile1
     outfile = self.outroot+tid+".out"
     try:
         result = sdlistold(infile=infile,outfile=outfile,overwrite=False)
         self.assertTrue(False,
                         msg='The task must throw exception')
     except Exception, e:
         pos=str(e).find('Output file \'%s\' exists.'%(outfile))
         self.assertNotEqual(pos,-1,
                             msg='Unexpected exception was thrown: %s'%(str(e)))
Beispiel #5
0
 def test02(self):
     """Test 2: Test overwrite=True"""
     tid = "02"
     infile = self.infile2
     outfile = self.outroot + tid + ".out"
     result = sdlistold(infile=infile, outfile=outfile)
     self.assertEqual(result,
                      None,
                      msg="The task returned '" + str(result) +
                      "' instead of None")
     self.assertTrue(os.path.exists(outfile),
                     msg="Output file doesn't exist after the 1st run.")
     # overwrite 'outfile'
     infile = self.infile1
     outfile = self.outroot + tid + ".out"
     result = sdlistold(infile=infile, outfile=outfile, overwrite=True)
     self.assertEqual(result,
                      None,
                      msg="The task returned '" + str(result) +
                      "' instead of None")
     self._compareOutFile(outfile, self.datapath + self.reffile)
Beispiel #6
0
 def test03(self):
     """Test 3: Test overwrite=False"""
     tid = "03"
     infile = self.infile2
     outfile = self.outroot + tid + ".out"
     result = sdlistold(infile=infile, outfile=outfile)
     self.assertEqual(result,
                      None,
                      msg="The task returned '" + str(result) +
                      "' instead of None")
     self.assertTrue(os.path.exists(outfile),
                     msg="Output file doesn't exist after the 1st run.")
     # overwrite 'outfile'
     infile = self.infile1
     outfile = self.outroot + tid + ".out"
     try:
         result = sdlistold(infile=infile, outfile=outfile, overwrite=False)
         self.assertTrue(False, msg='The task must throw exception')
     except Exception, e:
         pos = str(e).find('Output file \'%s\' exists.' % (outfile))
         self.assertNotEqual(pos,
                             -1,
                             msg='Unexpected exception was thrown: %s' %
                             (str(e)))
Beispiel #7
0
    def test04(self):
        """Test 4: Verify correct handling of flag information"""
        tid = "04"
        infile = self.infile_flag
        outfile = self.outroot + tid + ".out"
        result = sdlistold(infile=infile, outfile=outfile)
        rowinfo = []
        read_rowinfo = False
        with open(outfile, 'r') as f:
            for line in f:
                sline = line.strip()
                if sline.startswith('Data Records:'):
                    sline_elem = sline.split(' ')
                    self.assertEqual(int(sline_elem[len(sline_elem) - 2]), 4)
                elif sline.startswith('FREQUENCIES'):
                    read_rowinfo = True
                elif sline.startswith('-----'):
                    if read_rowinfo: read_rowinfo = False

                if read_rowinfo:
                    rowinfo.append(sline)
        self.assertTrue(len(rowinfo) == 5)
        del rowinfo[0:2]
        import re
        import string
        found_flaggedrow = [False, False]
        for i in xrange(len(rowinfo)):
            rowinfo_tmp = re.sub(r' +', ' ', rowinfo[i])
            rowinfo_elem = re.sub(r', +', ',', rowinfo_tmp).split(' ')
            rowinfo_if = rowinfo_elem[1]
            if rowinfo_if == '23':
                rowinfo_pollist = rowinfo_elem[7].translate(
                    string.maketrans('[]', '  ')).strip().split(',')
                try:
                    rowinfo_pollist.index('0')
                    found_flaggedrow[0] = True
                except:
                    pass
            if rowinfo_if == '25': found_flaggedrow[1] = True
        self.assertTrue(found_flaggedrow[0] and found_flaggedrow[1])
Beispiel #8
0
    def test04(self):
        """Test 4: Verify correct handling of flag information"""
        tid = "04"
        infile = self.infile_flag
        outfile = self.outroot+tid+".out"
        result = sdlistold(infile=infile, outfile=outfile)
        rowinfo = []
        read_rowinfo = False
        with open(outfile, 'r') as f:
            for line in f:
                sline = line.strip()
                if sline.startswith('Data Records:'):
                    sline_elem = sline.split(' ')
                    self.assertEqual(int(sline_elem[len(sline_elem)-2]), 4)
                elif sline.startswith('FREQUENCIES'):
                    read_rowinfo = True
                elif sline.startswith('-----'):
                    if read_rowinfo: read_rowinfo = False

                if read_rowinfo:
                    rowinfo.append(sline)
        self.assertTrue(len(rowinfo) == 5)
        del rowinfo[0:2]
        import re
        import string
        found_flaggedrow = [False, False]
        for i in xrange(len(rowinfo)):
            rowinfo_tmp = re.sub(r' +', ' ', rowinfo[i])
            rowinfo_elem = re.sub(r', +', ',', rowinfo_tmp).split(' ')
            rowinfo_if = rowinfo_elem[1]
            if rowinfo_if == '23':
                rowinfo_pollist = rowinfo_elem[7].translate(string.maketrans('[]','  ')).strip().split(',')
                try:
                    rowinfo_pollist.index('0')
                    found_flaggedrow[0] = True
                except:
                    pass
            if rowinfo_if == '25': found_flaggedrow[1] = True
        self.assertTrue(found_flaggedrow[0] and found_flaggedrow[1])
Beispiel #9
0
 def test00(self):
     """Test 0: Default parameters"""
     result=sdlistold()
     self.assertFalse(result)
Beispiel #10
0
 def test00(self):
     """Test 0: Default parameters"""
     result = sdlistold()
     self.assertFalse(result)