Exemplo n.º 1
0
 def testNumericMerge(self):
     os.write(self.tempfiles[0][0], "\n".join(['1 one', '5 five', '300 threehundred', 
                                         '500 fivehundred']))
     os.write(self.tempfiles[1][0], "\n".join(['-1 minusone', '0 zero',
                                         '670 sixhundredseventy' ,'1000 thousand']))
     os.write(self.tempfiles[2][0], "\n".join(['3 three', '22 twentytwo', '80 eighty']))
     
     options = AttrDict({'delimiter': ' ', 'field': 1, 'numeric': True })
     output = [(k, l) for k, l in logmerge(options, self.args)]
     
     self.assertEquals(len(output), 11, "Output size was not equal to input size!")
     self.assertEquals(map(itemgetter(0), output), sorted(map(lambda x: int(x[0]), output)), 
                       "Output was not numerically sorted!")
Exemplo n.º 2
0
 def testNumericMerge(self):
     os.write(self.tempfiles[0][0], "\n".join(['1 one', '5 five', '300 threehundred', 
                                         '500 fivehundred']))
     os.write(self.tempfiles[1][0], "\n".join(['-1 minusone', '0 zero',
                                         '670 sixhundredseventy' ,'1000 thousand']))
     os.write(self.tempfiles[2][0], "\n".join(['3 three', '22 twentytwo', '80 eighty']))
     
     options = AttrDict({'delimiter': ' ', 'field': 1, 'numeric': True })
     output = [(k, l) for k, l in logmerge(options, self.args)]
     
     self.assertEquals(len(output), 11, "Output size was not equal to input size!")
     self.assertEquals(map(itemgetter(0), output), sorted(map(lambda x: int(x[0]), output)), 
                       "Output was not numerically sorted!")
Exemplo n.º 3
0
 def testDateMerge(self):
     os.write(self.tempfiles[0][0], "\n".join(['2010/01/12 07:00:00,one', '2010/01/12 08:00:00,five', 
                                               '2010/01/13 10:00:00,threehundred']))
     os.write(self.tempfiles[1][0], "\n".join(['2010/01/12 07:30:00,one', '2010/01/12 08:10:00,five', 
                                               '2010/01/12 21:00:00,threehundred']))
     os.write(self.tempfiles[2][0], "\n".join(['2010/01/11 05:33:03,one', '2010/01/12 03:10:00,five', 
                                               '2010/01/21 22:00:00,threehundred']))
     
     dateformat = '%Y/%m/%d %H:%M:%S'
     options = AttrDict({'delimiter': ',', 'field': 1, 'datetime': True, 'dateformat': dateformat })
     output = [(k, l) for k, l in logmerge(options, self.args)]
     
     self.assertEquals(len(output), 9, "Output size was not equal to input size!")
     self.assertEquals(map(itemgetter(0), output), sorted(map(itemgetter(0), output)), 
                       "Output was not time sorted!")