X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Fdbtest_contents.py;h=90fe49666484a6e35ee19ac688fe0a440f7dfc4b;hb=008ec05c90d3130241fc7869c5b38a6a33fc71c8;hp=9b33c04be9655497b132ea6393cf288afb0930ae;hpb=1b3315533c0a701972e1636e809cf30106ee5424;p=dak.git diff --git a/tests/dbtest_contents.py b/tests/dbtest_contents.py index 9b33c04b..90fe4966 100755 --- a/tests/dbtest_contents.py +++ b/tests/dbtest_contents.py @@ -1,11 +1,13 @@ #!/usr/bin/env python -from db_test import DBDakTestCase +from db_test import DBDakTestCase, fixture from daklib.dbconn import * -from daklib.contents import ContentsWriter +from daklib.contents import ContentsWriter, ContentsScanner, UnpackedSource +from os.path import normpath from sqlalchemy.exc import FlushError, IntegrityError +from subprocess import CalledProcessError import unittest class ContentsTestCase(DBDakTestCase): @@ -140,20 +142,51 @@ class ContentsTestCase(DBDakTestCase): self.binary['hello_2.2-1_i386'].contents.append(BinContents(file = '/usr/bin/hello')) self.session.commit() cw = ContentsWriter(self.suite['squeeze'], self.arch['i386'], self.otype['deb']) - self.assertEqual(['/usr/bin/hello python/hello\n'], \ + self.assertEqual(['/usr/bin/hello python/hello\n'], \ cw.get_list()) # test formatline and sort order - self.assertEqual('/usr/bin/hello python/hello\n', \ - cw.formatline('/usr/bin/hello', ['python/hello'])) - self.assertEqual('/usr/bin/hello editors/emacs,python/hello,utils/sl\n', \ - cw.formatline('/usr/bin/hello', ['editors/emacs', 'python/hello', 'utils/sl'])) + self.assertEqual('/usr/bin/hello python/hello\n', \ + cw.formatline('/usr/bin/hello', 'python/hello')) # test output_filename - self.assertEqual('tests/fixtures/ftp/squeeze/Contents-i386.gz', \ - cw.output_filename()) + self.assertEqual('tests/fixtures/ftp/dists/squeeze/Contents-i386.gz', \ + normpath(cw.output_filename())) cw = ContentsWriter(self.suite['squeeze'], self.arch['i386'], \ self.otype['udeb'], self.comp['main']) - self.assertEqual('tests/fixtures/ftp/squeeze/main/Contents-i386.gz', \ - cw.output_filename()) + self.assertEqual('tests/fixtures/ftp/dists/squeeze/main/Contents-i386.gz', \ + normpath(cw.output_filename())) + # test unicode support + self.binary['hello_2.2-1_i386'].contents.append(BinContents(file = '\xc3\xb6')) + self.session.commit() + # test delete cascading + self.session.delete(self.binary['hello_2.2-1_i386']) + self.session.commit() + + def test_scan_contents(self): + self.setup_binaries() + filelist = [f for f in self.binary['hello_2.2-1_i386'].scan_contents()] + self.assertEqual(['usr/bin/hello', 'usr/share/doc/hello/copyright'], + filelist) + self.session.commit() + ContentsScanner(self.binary['hello_2.2-1_i386'].binary_id).scan() + bin_contents_list = self.binary['hello_2.2-1_i386'].contents.order_by('file').all() + self.assertEqual(2, len(bin_contents_list)) + self.assertEqual('usr/bin/hello', bin_contents_list[0].file) + self.assertEqual('usr/share/doc/hello/copyright', bin_contents_list[1].file) + + def test_unpack(self): + ''' + Tests the UnpackedSource class. + ''' + self.setup_poolfiles() + dscfilename = fixture('ftp/pool/' + self.file['hello_2.2-1.dsc'].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) + self.assertRaises(CalledProcessError, lambda: UnpackedSource('invalidname')) def classes_to_clean(self): return [Override, Suite, BinContents, DBBinary, DBSource, Architecture, Section, \