]> err.no Git - dak/commitdiff
Add a test for get_suite_architectures().
authorTorsten Werner <twerner@debian.org>
Sun, 16 Jan 2011 15:34:32 +0000 (16:34 +0100)
committerTorsten Werner <twerner@debian.org>
Sun, 16 Jan 2011 16:13:36 +0000 (17:13 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_packages.py

index 59fe5dc3c0f6fd5a1ce8c8ca1edda8958b4064cf..5e05c34b1c7ead15b4513e76f443586277668183 100755 (executable)
@@ -2590,6 +2590,7 @@ __all__.append('get_suite')
 
 ################################################################################
 
+# TODO: remove SuiteArchitecture class
 class SuiteArchitecture(object):
     def __init__(self, *args, **kwargs):
         pass
index e36b3ba70598848acb2bf3c0ffbe40556d4d3879..f1ac75b89b1c35c495648c50be03adf991168767 100755 (executable)
@@ -2,7 +2,7 @@
 
 from db_test import DBDakTestCase
 
-from daklib.dbconn import Architecture, Suite
+from daklib.dbconn import Architecture, Suite, get_suite_architectures
 
 import unittest
 
@@ -16,7 +16,7 @@ class PackageTestCase(DBDakTestCase):
         "setup a hash of Architecture objects in self.arch"
 
         self.arch = {}
-        for arch_string in ('source', 'all', 'i386', 'amd64'):
+        for arch_string in ('source', 'all', 'i386', 'amd64', 'kfreebsd-i386'):
             self.arch[arch_string] = Architecture(arch_string)
         # hard code ids for source and all
         self.arch['source'].arch_id = 1
@@ -42,13 +42,45 @@ class PackageTestCase(DBDakTestCase):
         self.setup_architectures()
         self.setup_suites()
 
-    def test_packages(self):
+    def connect_suite_architectures(self):
+        """
+        Gonnect all suites and all architectures except for kfreebsd-i386 which
+        should not be in lenny.
+        """
+
+        for arch_string, architecture in self.arch.items():
+            if arch_string != 'kfreebsd-i386':
+                architecture.suites = self.suite.values()
+            else:
+                architecture.suites = [self.suite['squeeze'], self.suite['sid']]
+
+    def test_suite_architecture(self):
         # check the id for architectures source and all
         self.assertEqual(1, self.arch['source'].arch_id)
         self.assertEqual(2, self.arch['all'].arch_id)
         # check the many to many relation between Suite and Architecture
         self.arch['source'].suites.append(self.suite['lenny'])
         self.assertEqual('source', self.suite['lenny'].architectures[0])
+        self.arch['source'].suites = []
+        self.assertEqual([], self.suite['lenny'].architectures)
+        self.connect_suite_architectures()
+        self.assertEqual(4, len(self.suite['lenny'].architectures))
+        self.assertEqual(3, len(self.arch['i386'].suites))
+        # check the function get_suite_architectures()
+        architectures = get_suite_architectures('lenny', session = self.session)
+        self.assertEqual(4, len(architectures))
+        self.assertTrue(self.arch['source'] in architectures)
+        self.assertTrue(self.arch['all'] in architectures)
+        self.assertTrue(self.arch['kfreebsd-i386'] not in architectures)
+        architectures = get_suite_architectures('sid', session = self.session)
+        self.assertEqual(5, len(architectures))
+        self.assertTrue(self.arch['kfreebsd-i386'] in architectures)
+        architectures = get_suite_architectures('lenny', skipsrc = True, session = self.session)
+        self.assertEqual(3, len(architectures))
+        self.assertTrue(self.arch['source'] not in architectures)
+        architectures = get_suite_architectures('lenny', skipall = True, session = self.session)
+        self.assertEqual(3, len(architectures))
+        self.assertTrue(self.arch['all'] not in architectures)
 
 if __name__ == '__main__':
     unittest.main()