]> err.no Git - dak/commitdiff
Refactor maintainer tests.
authorTorsten Werner <twerner@debian.org>
Thu, 20 Jan 2011 19:31:23 +0000 (20:31 +0100)
committerTorsten Werner <twerner@debian.org>
Thu, 20 Jan 2011 19:31:23 +0000 (20:31 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
tests/dbtest_packages.py

index 279d5a0f06702f0d66a4d3301a45f80d51bdf039..c35123ce56c786ce5d2c7c94d7f44bb4a97ecb44 100755 (executable)
@@ -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__':