+ 'test relation between DBSource and PoolFile or Suite'
+
+ self.setup_sources()
+ # test PoolFile
+ self.assertEqual(self.file['hello'], self.source['hello'].poolfile)
+ self.assertEqual(self.source['hello'], self.file['hello'].source)
+ self.assertEqual(None, self.file['python'].source)
+ # test Suite
+ squeeze = self.session.query(Suite). \
+ filter(Suite.sources.contains(self.source['sl'])). \
+ order_by(Suite.suite_name)[1]
+ self.assertEqual(self.suite['squeeze'], squeeze)
+ self.assertEqual(1, len(squeeze.sources))
+ self.assertEqual(self.source['sl'], squeeze.sources[0])
+ sl = self.session.query(DBSource). \
+ filter(DBSource.suites.contains(self.suite['squeeze'])).one()
+ self.assertEqual(self.source['sl'], 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'], \
+ 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_upload(self):
+ 'tests function add_dsc_to_db()'
+
+ self.setup_maintainers()
+ self.setup_locations()
+ self.setup_poolfiles()
+ pkg = Pkg()
+ pkg.dsc['source'] = 'hello'
+ pkg.dsc['version'] = '2.2-2'
+ pkg.dsc['maintainer'] = self.maintainer['maintainer'].name
+ pkg.changes['changed-by'] = self.maintainer['uploader'].name
+ pkg.changes['fingerprint'] = 'deadbeef'
+ pkg.changes['distribution'] = { 'sid': '' }
+ self.session.flush()
+ self.session.refresh(self.file['hello'])
+ pkg.files['hello_2.2-2.dsc'] = { \
+ 'component': 'main',
+ 'location id': self.loc['main'].component_id,
+ 'files id': self.file['hello'].file_id }
+ pkg.dsc_files = {}
+ upload = Upload(pkg)
+ (source, dsc_component, dsc_location_id, pfs) = \
+ add_dsc_to_db(upload, 'hello_2.2-2.dsc', self.session)
+ self.session.refresh(source)
+ self.assertEqual('hello', source.source)
+ self.assertEqual('2.2-2', source.version)
+ self.assertEqual('sid', source.suites[0].suite_name)
+ self.assertEqual('main', dsc_component)
+ # no dsc files defined above
+ self.assertEqual(None, dsc_location_id)
+ self.assertEqual([], pfs)
+
+ def test_source_exists(self):
+ 'test function source_exists()'
+
+ self.setup_sources()
+ self.session.flush()
+ hello = self.source['hello']
+ 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()'