3 from db_test import DBDakTestCase
5 from daklib.dbconn import *
6 from daklib.cruft import *
10 class CruftTestCase(DBDakTestCase):
12 This class checks various functions of cruft-report.
16 super(CruftTestCase, self).setUp()
18 # flush to make sure that the setup is correct
21 def test_newer_version(self):
22 'tests newer_version()'
24 list = newer_version('squeeze', 'sid', self.session)
25 self.assertEqual([], list)
26 self.file['sl_3.03-17.dsc'] = PoolFile(filename = 'main/s/sl/sl_3.03-17.dsc', \
27 location = self.loc['main'], filesize = 0, md5sum = '')
28 self.source['sl_3.03-17'] = DBSource(source = 'sl', version = '3.03-17', \
29 maintainer = self.maintainer['maintainer'], \
30 changedby = self.maintainer['uploader'], \
31 poolfile = self.file['sl_3.03-17.dsc'], install_date = self.now())
32 self.source['sl_3.03-17'].suites.append(self.suite['squeeze'])
33 list = newer_version('squeeze', 'sid', self.session)
34 self.assertEqual([('sl', '3.03-16', '3.03-17')], list)
36 def test_multiple_source(self):
37 'tests functions related to report_multiple_source()'
39 # test get_package_names()
40 suite = get_suite('sid', self.session)
41 self.assertEqual([('gnome-hello', ), ('hello', )], \
42 get_package_names(suite).all())
43 # test class NamedSource
44 src = NamedSource(suite, 'hello')
45 self.assertEqual('hello', src.source)
46 self.assertEqual(['2.2-1', '2.2-2'], src.versions)
47 self.assertEqual('hello(2.2-1, 2.2-2)', str(src))
48 # test class DejavuBinary
49 bin = DejavuBinary(suite, 'hello')
50 self.assertEqual(False, bin.has_multiple_sources())
52 self.file['hello_2.2-3'] = PoolFile(filename = 'main/s/sl/hello_2.2-3_i386.deb', \
53 location = self.loc['main'], filesize = 0, md5sum = '')
54 self.binary['hello_2.2-3_i386'] = DBBinary(package = 'hello', \
55 source = self.source['sl_3.03-16'], version = '2.2-3', \
56 maintainer = self.maintainer['maintainer'], \
57 architecture = self.arch['i386'], \
58 poolfile = self.file['hello_2.2-3'])
59 self.session.add(self.binary['hello_2.2-3_i386'])
60 bin = DejavuBinary(suite, 'hello')
61 self.assertEqual(False, bin.has_multiple_sources())
63 self.binary['hello_2.2-3_i386'].suites.append(self.suite['sid'])
64 bin = DejavuBinary(suite, 'hello')
65 self.assertEqual(True, bin.has_multiple_sources())
66 self.assertEqual('hello built by: hello(2.2-1, 2.2-2), sl(3.03-16)', \
69 if __name__ == '__main__':