+ Add a test.
Signed-off-by: Torsten Werner <twerner@debian.org>
################################################################################
-class Override(object):
- def __init__(self, *args, **kwargs):
- pass
+class Override(ORMObject):
+ def __init__(self, package = None, suite = None, component = None, overridetype = None, \
+ section = None, priority = None):
+ self.package = package
+ self.suite = suite
+ self.component = component
+ self.overridetype = overridetype
+ self.section = section
+ self.priority = priority
- def __repr__(self):
- return '<Override %s (%s)>' % (self.package, self.suite_id)
+ def properties(self):
+ return ['package', 'suite', 'component', 'overridetype', 'section', \
+ 'priority']
+
+ def not_null_constraints(self):
+ return ['package', 'suite', 'component', 'overridetype', 'section']
__all__.append('Override')
if 'otype' in self.__dict__:
return
self.otype = {}
- self.otype['deb'] = OverrideType(overridetype = 'deb')
+ for type_ in ('deb', 'udeb'):
+ self.otype[type_] = OverrideType(overridetype = type_)
self.session.add_all(self.otype.values())
self.session.flush()
self.session.add_all(self.prio.values())
self.session.flush()
+ def setup_overrides(self):
+ '''
+ Setup self.override of class Override.
+ '''
+ if 'override' in self.__dict__:
+ return
+ self.setup_suites()
+ self.setup_components()
+ self.setup_overridetypes()
+ self.setup_sections()
+ self.setup_priorities()
+ self.override = {}
+ self.override['hello_sid_main_udeb'] = Override(package = 'hello', \
+ suite = self.suite['sid'], component = self.comp['main'], \
+ overridetype = self.otype['udeb'], \
+ section = self.section['python'], priority = self.prio['standard'])
+ self.override['hello_squeeze_main_deb'] = Override(package = 'hello', \
+ suite = self.suite['squeeze'], component = self.comp['main'], \
+ overridetype = self.otype['deb'], \
+ section = self.section['python'], priority = self.prio['standard'])
+ self.override['hello_lenny_contrib_deb'] = Override(package = 'hello', \
+ suite = self.suite['lenny'], component = self.comp['contrib'], \
+ overridetype = self.otype['deb'], \
+ section = self.section['python'], priority = self.prio['standard'])
+ self.session.add_all(self.override.values())
+ self.session.flush()
+
def setUp(self):
if self.metadata is None:
self.initialize()
from db_test import DBDakTestCase
from daklib.dbconn import DBConn, BinContents, OverrideType, get_override_type, \
- Section, get_section, get_sections, Priority, get_priority, get_priorities
+ Section, get_section, get_sections, Priority, get_priority, get_priorities, \
+ Override, get_override
from sqlalchemy.exc import FlushError, IntegrityError
import unittest
self.assertEqual(self.prio['standard'].priority_id, all_priorities['standard'])
self.assertEqual(0, self.prio['standard'].overrides.count())
+ def test_override(self):
+ '''
+ Test Override class.
+ '''
+ self.setup_overrides()
+ list = get_override('hello', session = self.session)
+ self.assertEqual(3, len(list))
+ self.assertTrue(self.override['hello_sid_main_udeb'] in list)
+ self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
+ list = get_override('hello', suite = 'sid', session = self.session)
+ self.assertEqual([self.override['hello_sid_main_udeb']], list)
+ list = get_override('hello', suite = ['sid'], session = self.session)
+ self.assertEqual([self.override['hello_sid_main_udeb']], list)
+ list = get_override('hello', component = 'contrib', session = self.session)
+ self.assertEqual([self.override['hello_lenny_contrib_deb']], list)
+ list = get_override('hello', component = ['contrib'], session = self.session)
+ self.assertEqual([self.override['hello_lenny_contrib_deb']], list)
+ list = get_override('hello', overridetype = 'deb', session = self.session)
+ self.assertEqual(2, len(list))
+ self.assertTrue(self.override['hello_sid_main_udeb'] not in list)
+ self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
+ list = get_override('hello', overridetype = ['deb'], session = self.session)
+ self.assertEqual(2, len(list))
+ self.assertTrue(self.override['hello_sid_main_udeb'] not in list)
+ self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
+
if __name__ == '__main__':
unittest.main()