From: Torsten Werner Date: Thu, 20 Jan 2011 19:31:23 +0000 (+0100) Subject: Refactor maintainer tests. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea7b3aa2abcb81b9840c34e7b0060d0f83e93be7;p=dak Refactor maintainer tests. Signed-off-by: Torsten Werner --- diff --git a/tests/dbtest_packages.py b/tests/dbtest_packages.py index 279d5a0f..c35123ce 100755 --- a/tests/dbtest_packages.py +++ b/tests/dbtest_packages.py @@ -169,16 +169,18 @@ class PackageTestCase(DBDakTestCase): def setup_maintainers(self): 'create some Maintainer objects' - self.maintainer = Maintainer(name = 'Mr. Maintainer') - self.uploader = Maintainer(name = 'Mrs. Uploader') - self.lazyguy = Maintainer(name = 'Lazy Guy') - self.session.add_all([self.maintainer, self.uploader, self.lazyguy]) + self.maintainer = {} + self.maintainer['maintainer'] = Maintainer(name = 'Mr. Maintainer') + self.maintainer['uploader'] = Maintainer(name = 'Mrs. Uploader') + self.maintainer['lazyguy'] = Maintainer(name = 'Lazy Guy') + self.session.add_all(self.maintainer.values()) + self.session.flush() def setup_sources(self): 'create a DBSource object; but it cannot be stored in the DB yet' - self.source = DBSource(maintainer = self.maintainer, - changedby = self.uploader) + self.source = DBSource(maintainer = self.maintainer['maintainer'], + changedby = self.maintainer['uploader']) def test_maintainers(self): ''' @@ -188,20 +190,23 @@ class PackageTestCase(DBDakTestCase): ''' self.setup_maintainers() - self.assertEqual('Mr. Maintainer', - self.session.query(Maintainer)[0].name) - self.assertEqual('Mrs. Uploader', - self.session.query(Maintainer)[1].name) - self.assertEqual('Lazy Guy', - self.session.query(Maintainer)[2].name) + maintainer = self.maintainer['maintainer'] + self.assertEqual(maintainer, + self.session.query(Maintainer).get(maintainer.maintainer_id)) + uploader = self.maintainer['uploader'] + self.assertEqual(uploader, + self.session.query(Maintainer).get(uploader.maintainer_id)) + lazyguy = self.maintainer['lazyguy'] + self.assertEqual(lazyguy, + self.session.query(Maintainer).get(lazyguy.maintainer_id)) self.setup_sources() #TODO: needs File and Location - #self.assertEqual(self.maintainer.maintains_sources, [self.source]) - #self.assertEqual(self.maintainer.changed_sources, []) - #self.assertEqual(self.uploader.maintains_sources, []) - #self.assertEqual(self.uploader.changed_sources, [self.source]) - #self.assertEqual(self.lazyguy.maintains_sources, []) - #self.assertEqual(self.lazyguy.changed_sources, []) + #self.assertEqual(maintainer.maintains_sources, [self.source]) + #self.assertEqual(maintainer.changed_sources, []) + #self.assertEqual(uploader.maintains_sources, []) + #self.assertEqual(uploader.changed_sources, [self.source]) + #self.assertEqual(lazyguy.maintains_sources, []) + #self.assertEqual(lazyguy.changed_sources, []) if __name__ == '__main__':