예제 #1
0
파일: tests_file.py 프로젝트: gisce/sippers
 def test_iterator_file(self):
     for dso in self.SIPS_DATA:
         sips_file = self.SIPS_DATA[dso]['file']
         sf = SipsFile(sips_file)
         with codecs.open(self.SIPS_DATA[dso]['file'],
                          encoding=sf.parser.encoding) as orig:
             orig_content = orig.read()
         content = ''
         for line in sf:
             content += line['orig']
         self.assertEqual(orig_content, content)
         sf.close()
예제 #2
0
파일: tests_file.py 프로젝트: gisce/sippers
 def test_stats(self):
     for dso in self.SIPS_DATA:
         sips_file = self.SIPS_DATA[dso]['file']
         line_numbers = len(open(sips_file, 'r').readlines())
         path = get_data(sips_file)
         sf = SipsFile(path)
         for _ in sf:
             read = sf.stats.read
             progress = sf.stats.progress
         self.assertEqual(progress, '100%')
         self.assertEqual(sf.stats.line_number, line_numbers)
         self.assertEqual(naturalsize(read), sf.stats.size)
         sf.close()
예제 #3
0
파일: tests_file.py 프로젝트: gisce/sippers
 def test_resume(self):
     sips_file = self.SIPS_DATA['IBERDROLA']['file']
     path = get_data(sips_file)
     sf = SipsFile(path)
     with codecs.open(sips_file, encoding=sf.parser.encoding) as orig:
         orig_content = orig.read()
     content = ''
     for idx, line in enumerate(sf):
         content += line['orig']
         if idx == 5:
             break
     sf.close()
     stats = sf.stats
     sf = SipsFile(path, resume=stats)
     self.assertEqual(sf.resume_line_number, 6)
     for line in sf:
         content += line['orig']
     sf.close()
     self.assertEqual(orig_content, content)
예제 #4
0
 def test_assign_parser(self):
     for dso in self.SIPS_DATA:
         sips_file = self.SIPS_DATA[dso]['file']
         sips = SipsFile(sips_file)
         parser = sips.parser.__class__
         path = '.'.join([parser.__module__, parser.__name__])
         self.assertEquals(
             COMPANY_PARSERS[dso],
             path
         )
         sips.close()
     for dso in self.SIPS_PACKED_DATA:
         sips_file = self.SIPS_PACKED_DATA[dso]['file']
         sips = PackedSipsFile(sips_file)
         parser = sips.parser.__class__
         path = '.'.join([parser.__module__, parser.__name__])
         self.assertEquals(
             COMPANY_PARSERS[dso],
             path
         )
         sips.close()