+ 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()'
+
+ self.setup_sources()
+ 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'].source
+ pkg.changes['version'] = self.source['hello'].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'].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'
+