+ # test Suite relation
+ self.assertEqual(3, self.suite['sid'].binaries.count())
+ self.assertTrue(self.binary['hello_2.2-1_i386'] in \
+ self.suite['sid'].binaries.all())
+ self.assertEqual(0, self.suite['lenny'].binaries.count())
+ # test DBSource relation
+ self.assertEqual(3, len(self.source['hello_2.2-1'].binaries))
+ self.assertTrue(self.binary['hello_2.2-1_i386'] in \
+ self.source['hello_2.2-1'].binaries)
+ self.assertEqual(0, len(self.source['hello_2.2-2'].binaries))
+ # test get_suites_binary_in()
+ self.assertEqual(2, len(get_suites_binary_in('hello', self.session)))
+ self.assertTrue(self.suite['sid'] in \
+ get_suites_binary_in('hello', self.session))
+ self.assertEqual(2, len(get_suites_binary_in('gnome-hello', self.session)))
+ self.assertTrue(self.suite['squeeze'] in \
+ get_suites_binary_in('gnome-hello', self.session))
+ self.assertEqual(0, len(get_suites_binary_in('sl', self.session)))
+
+ def test_add_deb_to_db(self):
+ 'tests function add_deb_to_db()'
+
+ pkg = Pkg()
+ pkg.changes['fingerprint'] = 'deadbeef'
+ pkg.changes['distribution'] = { 'sid': '' }
+ pkg.files['hello_2.2-2_i386.deb'] = { \
+ 'package': 'hello',
+ 'version': '2.2-2',
+ 'maintainer': self.maintainer['maintainer'].name,
+ 'architecture': 'i386',
+ 'dbtype': 'deb',
+ 'pool name': 'main/h/hello/',
+ 'location id': self.loc['main'].location_id,
+ 'source package': 'hello',
+ 'source version': '2.2-2',
+ 'size': 0,
+ 'md5sum': 'deadbeef',
+ 'sha1sum': 'deadbeef',
+ 'sha256sum': 'deadbeef'}
+ upload = Upload(pkg)
+ poolfile = add_deb_to_db(upload, 'hello_2.2-2_i386.deb', self.session)
+ self.session.refresh(poolfile)
+ self.session.refresh(poolfile.binary)
+ self.assertEqual('main/h/hello/hello_2.2-2_i386.deb', poolfile.filename)
+ self.assertEqual('hello', poolfile.binary.package)
+ self.assertEqual('2.2-2', poolfile.binary.version)
+ self.assertEqual(['sid'], poolfile.binary.suites)
+ self.assertEqual('Mr. Maintainer', poolfile.binary.maintainer.name)
+ self.assertEqual('i386', poolfile.binary.architecture.arch_string)
+ self.assertEqual('deb', poolfile.binary.binarytype)
+ self.assertEqual(self.loc['main'], poolfile.location)
+ self.assertEqual(self.source['hello_2.2-2'], poolfile.binary.source)
+ self.assertEqual(0, poolfile.filesize)
+ self.assertEqual('deadbeef', poolfile.md5sum)
+ self.assertEqual('deadbeef', poolfile.sha1sum)
+ self.assertEqual('deadbeef', poolfile.sha256sum)
+
+ def test_get_source_by_package_and_suite(self):
+ 'test get_source_by_package_and_suite()'
+
+ query = get_source_by_package_and_suite('hello', 'sid', self.session)
+ self.assertEqual(self.source['hello_2.2-1'], query.one())
+ query = get_source_by_package_and_suite('gnome-hello', 'squeeze', self.session)
+ self.assertEqual(self.source['hello_2.2-1'], query.one())
+ query = get_source_by_package_and_suite('hello', 'hamm', self.session)
+ self.assertEqual(0, query.count())
+ query = get_source_by_package_and_suite('foobar', 'squeeze', self.session)
+ self.assertEqual(0, query.count())
+
+ def test_get_suite_version_by_package(self):
+ 'test function get_suite_version_by_package()'
+
+ result = get_suite_version_by_package('hello', 'i386', self.session)
+ self.assertEqual(2, len(result))
+ self.assertTrue(('sid', '2.2-1') in result)
+ result = get_suite_version_by_package('hello', 'amd64', self.session)
+ self.assertEqual(0, len(result))
+ result = get_suite_version_by_package('python-hello', 'i386', self.session)
+ self.assertEqual([('squeeze', '2.2-1')], result)
+ result = get_suite_version_by_package('python-hello', 'amd64', self.session)
+ self.assertEqual([('squeeze', '2.2-1')], result)
+
+ def test_components(self):
+ 'test class Component'
+
+ self.assertEqual(self.loc['main'], self.comp['main'].location)
+ self.assertEqual(self.loc['contrib'], self.comp['contrib'].location)
+
+ def test_get_component_by_package_suite(self):
+ 'test get_component_by_package_suite()'
+
+ result = get_component_by_package_suite('hello', ['sid'], \
+ session = self.session)
+ self.assertEqual('main', result)
+ result = get_component_by_package_suite('hello', ['hamm'], \
+ session = self.session)
+ self.assertEqual(None, result)
+ result = get_component_by_package_suite('foobar', ['sid'], \
+ session = self.session)
+ self.assertEqual(None, result)
+ # test that the newest version is returned
+ result = get_component_by_package_suite('gnome-hello', ['squeeze'], \
+ session = self.session)
+ self.assertEqual('main', result)
+ result = get_component_by_package_suite('gnome-hello', ['sid'], \
+ session = self.session)
+ self.assertEqual('contrib', result)
+ # test arch_list
+ result = get_component_by_package_suite('hello', ['sid'], \
+ arch_list = ['i386'], session = self.session)
+ self.assertEqual('main', result)
+ result = get_component_by_package_suite('hello', ['sid'], \
+ arch_list = ['amd64'], session = self.session)
+ self.assertEqual(None, result)