+ return get_source_in_suite('hello', 'sid', self.session)
+
+ def test_sources(self):
+ 'test relation between DBSource and PoolFile or Suite'
+
+ # test PoolFile
+ self.assertEqual(self.file['hello_2.2-2.dsc'], self.source['hello_2.2-2'].poolfile)
+ self.assertEqual(self.source['hello_2.2-2'], self.file['hello_2.2-2.dsc'].source)
+ self.assertEqual(None, self.file['python2.6_2.6.6-8.dsc'].source)
+ # test Suite
+ squeeze = self.session.query(Suite). \
+ filter(Suite.sources.contains(self.source['sl_3.03-16'])). \
+ order_by(Suite.suite_name)[1]
+ self.assertEqual(self.suite['squeeze'], squeeze)
+ self.assertEqual(1, squeeze.sources.count())
+ self.assertEqual(self.source['sl_3.03-16'], squeeze.sources[0])
+ sl = self.session.query(DBSource). \
+ filter(DBSource.suites.contains(self.suite['squeeze'])).one()
+ self.assertEqual(self.source['sl_3.03-16'], sl)
+ self.assertEqual(2, len(sl.suites))
+ self.assertTrue(self.suite['sid'] in sl.suites)
+ # test get_source_in_suite()
+ self.assertRaises(MultipleResultsFound, self.get_source_in_suite_fail)
+ self.assertEqual(None, \
+ get_source_in_suite('hello', 'squeeze', self.session))
+ self.assertEqual(self.source['sl_3.03-16'], \
+ get_source_in_suite('sl', 'sid', self.session))
+ # test get_suites_source_in()
+ self.assertEqual([self.suite['sid']], \
+ get_suites_source_in('hello', self.session))
+ self.assertEqual(2, len(get_suites_source_in('sl', self.session)))
+ self.assertTrue(self.suite['squeeze'] in \
+ get_suites_source_in('sl', self.session))
+
+ def test_add_dsc_to_db(self):
+ 'tests function add_dsc_to_db()'
+
+ pkg = Pkg()
+ pkg.dsc['source'] = 'hello'
+ pkg.dsc['version'] = '2.2-3'
+ pkg.dsc['maintainer'] = self.maintainer['maintainer'].name
+ pkg.changes['changed-by'] = self.maintainer['uploader'].name
+ pkg.changes['fingerprint'] = 'deadbeef'
+ pkg.changes['distribution'] = { 'sid': '' }
+ pkg.files['hello_2.2-3.dsc'] = { \
+ 'component': 'main',
+ 'location id': self.loc['main'].location_id,
+ 'files id': self.file['hello_2.2-3.dsc'].file_id }
+ pkg.dsc_files = {}
+ upload = Upload(pkg)
+ (source, dsc_component, dsc_location_id, pfs) = \
+ add_dsc_to_db(upload, 'hello_2.2-3.dsc', self.session)
+ self.assertEqual('hello', source.source)
+ self.assertEqual('2.2-3', source.version)
+ self.assertEqual('sid', source.suites[0].suite_name)
+ self.assertEqual('main', dsc_component)
+ self.assertEqual(self.loc['main'].location_id, dsc_location_id)
+ self.assertEqual([], pfs)
+
+ def test_source_exists(self):
+ 'test function source_exists()'
+
+ hello = self.source['hello_2.2-2']
+ self.assertTrue(source_exists(hello.source, hello.version, \
+ suites = ['sid'], session = self.session))
+ # binNMU
+ self.assertTrue(source_exists(hello.source, hello.version + '+b7', \
+ suites = ['sid'], session = self.session))
+ self.assertTrue(not source_exists(hello.source, hello.version, \
+ suites = ['lenny', 'squeeze'], session = self.session))
+ self.assertTrue(not source_exists(hello.source, hello.version, \
+ suites = ['lenny', 'sid'], session = self.session))
+ self.assertTrue(not source_exists(hello.source, hello.version, \
+ suites = ['sid', 'lenny'], session = self.session))
+ self.assertTrue(not source_exists(hello.source, '0815', \
+ suites = ['sid'], session = self.session))
+ # 'any' suite
+ self.assertTrue(source_exists(hello.source, hello.version, \
+ session = self.session))
+
+ def test_package_to_suite(self):
+ 'test function package_to_suite()'
+
+ pkg = Pkg()
+ pkg.changes = { 'distribution': {} }
+ upload = Upload(pkg)
+ self.assertTrue(not package_to_suite(upload, 'sid', self.session))
+ pkg.changes['distribution'] = { 'sid': '' }
+ pkg.changes['architecture'] = { 'source': '' }
+ self.assertTrue(package_to_suite(upload, 'sid', self.session))
+ pkg.changes['architecture'] = {}
+ pkg.changes['source'] = self.source['hello_2.2-2'].source
+ pkg.changes['version'] = self.source['hello_2.2-2'].version
+ self.assertTrue(not package_to_suite(upload, 'sid', self.session))
+ pkg.changes['version'] = '42'
+ self.assertTrue(package_to_suite(upload, 'sid', self.session))
+ pkg.changes['source'] = 'foobar'
+ pkg.changes['version'] = self.source['hello_2.2-2'].version
+ self.assertTrue(package_to_suite(upload, 'sid', self.session))
+ pkg.changes['distribution'] = { 'lenny': '' }
+ self.assertTrue(package_to_suite(upload, 'lenny', self.session))
+
+ def test_get_newest_source(self):
+ 'test function get_newest_source()'
+
+ import daklib.queue
+ daklib.queue.dm_suites = ['sid']
+ self.assertEqual(self.source['hello_2.2-2'], get_newest_source('hello', self.session))
+ self.assertEqual(None, get_newest_source('foobar', self.session))
+
+ def test_get_suite_version_by_source(self):
+ 'test function get_suite_version_by_source()'
+
+ result = get_suite_version_by_source('hello', self.session)
+ self.assertEqual(2, len(result))
+ self.assertTrue(('sid', '2.2-1') in result)
+ self.assertTrue(('sid', '2.2-2') in result)
+ result = get_suite_version_by_source('sl', self.session)
+ self.assertEqual(2, len(result))
+ self.assertTrue(('squeeze', '3.03-16') in result)
+ self.assertTrue(('sid', '3.03-16') in result)
+
+ def test_binaries(self):
+ '''
+ tests class DBBinary; TODO: test relation with Architecture, Maintainer,
+ PoolFile, and Fingerprint