From: Torsten Werner Date: Sun, 16 Jan 2011 15:34:32 +0000 (+0100) Subject: Add a test for get_suite_architectures(). X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e09846088b4af7a5958230c2705ca39ca6d3bfa2;p=dak Add a test for get_suite_architectures(). Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 59fe5dc3..5e05c34b 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2590,6 +2590,7 @@ __all__.append('get_suite') ################################################################################ +# TODO: remove SuiteArchitecture class class SuiteArchitecture(object): def __init__(self, *args, **kwargs): pass diff --git a/tests/dbtest_packages.py b/tests/dbtest_packages.py index e36b3ba7..f1ac75b8 100755 --- a/tests/dbtest_packages.py +++ b/tests/dbtest_packages.py @@ -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()