Beispiel #1
0
 def test_unpack(self):
     '''
     Tests the UnpackedSource class and the SourceContentsScanner.
     '''
     self.setup_sources()
     source = self.source['hello_2.2-1']
     dscfilename = fixture('ftp/pool/' + source.poolfile.filename)
     unpacked = UnpackedSource(dscfilename)
     self.assertTrue(len(unpacked.get_root_directory()) > 0)
     self.assertEqual('hello (2.2-1) unstable; urgency=low\n',
         unpacked.get_changelog_file().readline())
     all_filenames = set(unpacked.get_all_filenames())
     self.assertEqual(8, len(all_filenames))
     self.assertTrue('debian/rules' in all_filenames)
     # method scan_contents()
     self.assertEqual(all_filenames, source.scan_contents())
     # exception with invalid files
     self.assertRaises(CalledProcessError, lambda: UnpackedSource('invalidname'))
     # SourceContentsScanner
     self.session.commit()
     self.assertTrue(source.contents.count() == 0)
     SourceContentsScanner(source.source_id).scan()
     self.assertTrue(source.contents.count() > 0)
Beispiel #2
0
 def test_unpack(self):
     '''
     Tests the UnpackedSource class and the SourceContentsScanner.
     '''
     self.setup_sources()
     source = self.source['hello_2.2-1']
     dscfilename = fixture('ftp/pool/' + source.poolfile.filename)
     unpacked = UnpackedSource(dscfilename)
     self.assertTrue(len(unpacked.get_root_directory()) > 0)
     self.assertEqual('hello (2.2-1) unstable; urgency=low\n',
                      unpacked.get_changelog_file().readline())
     all_filenames = set(unpacked.get_all_filenames())
     self.assertEqual(8, len(all_filenames))
     self.assertTrue('debian/rules' in all_filenames)
     # method scan_contents()
     self.assertEqual(all_filenames, source.scan_contents())
     # exception with invalid files
     self.assertRaises(CalledProcessError,
                       lambda: UnpackedSource('invalidname'))
     # SourceContentsScanner
     self.session.commit()
     self.assertTrue(source.contents.count() == 0)
     SourceContentsScanner(source.source_id).scan()
     self.assertTrue(source.contents.count() > 0)