]> git.decadent.org.uk Git - dak.git/commitdiff
Add an incomplete test for Maintainer.
authorTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 20:12:33 +0000 (21:12 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 18 Jan 2011 20:12:33 +0000 (21:12 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_packages.py

index 6ea3aa398beaa1745795321e3d3d7bc3af2759f5..93ec11720379e99549272cae3af94718a2bfacba 100755 (executable)
@@ -1567,8 +1567,8 @@ __all__.append('get_location')
 ################################################################################
 
 class Maintainer(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, name = None):
+        self.name = name
 
     def __repr__(self):
         return '''<Maintainer '%s' (%s)>''' % (self.name, self.maintainer_id)
@@ -2106,8 +2106,9 @@ __all__.append('get_sections')
 ################################################################################
 
 class DBSource(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, maintainer = None, changedby = None):
+        self.maintainer = maintainer
+        self.changedby = changedby
 
     def __repr__(self):
         return '<DBSource %s (%s)>' % (self.source, self.version)
index 97cc8b10cacd497c9968b4dff70a15c70c8b9a3e..deca4812d3bc08ac6a158f30ad1f100432103ba4 100755 (executable)
@@ -3,7 +3,7 @@
 from db_test import DBDakTestCase
 
 from daklib.dbconn import Architecture, Suite, get_suite_architectures, \
-    get_architecture_suites
+    get_architecture_suites, Maintainer, DBSource
 
 import unittest
 
@@ -90,5 +90,43 @@ class PackageTestCase(DBDakTestCase):
         self.assertEqual(2, len(suites))
         self.assertTrue(self.suite['lenny'] not in suites)
 
+    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])
+
+    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)
+
+    def test_maintainers(self):
+        '''
+        tests relation between Maintainer and DBSource
+
+        TODO: add relations to changes_pending_source
+        '''
+
+        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)
+        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, [])
+
+
 if __name__ == '__main__':
     unittest.main()