################################################################################
-class Component(object):
- def __init__(self, *args, **kwargs):
- pass
+class Component(ORMObject):
+ def __init__(self, component_name = None):
+ self.component_name = component_name
def __eq__(self, val):
if isinstance(val, str):
# This signals to use the normal comparison operator
return NotImplemented
- def __repr__(self):
- return '<Component %s>' % self.component_name
+ def properties(self):
+ return ['component_name', 'component_id', 'description', 'location', \
+ 'meets_dfsg']
+
+ def not_null_constraints(self):
+ return ['component_name']
__all__.append('Component')
################################################################################
+# TODO: Why do we have a separate Location class? Can't it be fully integrated
+# into class Component?
class Location(ORMObject):
- def __init__(self, path = None):
+ def __init__(self, path = None, component = None):
self.path = path
+ self.component = component
# the column 'type' should go away, see comment at mapper
self.archive_type = 'pool'
mapper(Component, self.tbl_component,
properties = dict(component_id = self.tbl_component.c.id,
- component_name = self.tbl_component.c.name))
+ component_name = self.tbl_component.c.name),
+ extension = validator)
mapper(DBConfig, self.tbl_config,
properties = dict(config_id = self.tbl_config.c.id))
mapper(Location, self.tbl_location,
properties = dict(location_id = self.tbl_location.c.id,
component_id = self.tbl_location.c.component,
- component = relation(Component),
+ component = relation(Component, \
+ backref=backref('location', uselist = False)),
archive_id = self.tbl_location.c.archive,
archive = relation(Archive),
# FIXME: the 'type' column is old cruft and
get_architecture_suites, Maintainer, DBSource, Location, PoolFile, \
check_poolfile, get_poolfile_like_name, get_source_in_suite, \
get_suites_source_in, add_dsc_to_db, source_exists, DBBinary, \
- get_suites_binary_in, add_deb_to_db
+ get_suites_binary_in, add_deb_to_db, Component
from daklib.queue_install import package_to_suite
from daklib.queue import get_newest_source, get_suite_version_by_source, \
get_source_by_package_and_suite, get_suite_version_by_package
self.arch['all'].arch_id = 2
self.session.add_all(self.arch.values())
+ def setup_components(self):
+ 'create some Component objects'
+
+ if 'comp' in self.__dict__:
+ return
+ self.comp = {}
+ self.comp['main'] = Component(component_name = 'main')
+ self.comp['contrib'] = Component(component_name = 'contrib')
+ self.session.add_all(self.comp.values())
+
def setup_locations(self):
- 'create some Location objects, TODO: add component'
+ 'create some Location objects'
if 'loc' in self.__dict__:
return
+ self.setup_components()
self.loc = {}
- self.loc['main'] = Location(path = \
- '/srv/ftp-master.debian.org/ftp/pool/')
- self.loc['contrib'] = Location(path = \
- '/srv/ftp-master.debian.org/ftp/pool/')
+ self.loc['main'] = Location( \
+ path = '/srv/ftp-master.debian.org/ftp/pool/', \
+ component = self.comp['main'])
+ self.loc['contrib'] = Location( \
+ path = '/srv/ftp-master.debian.org/ftp/pool/', \
+ component = self.comp['contrib'])
self.session.add_all(self.loc.values())
def setup_poolfiles(self):
result = get_suite_version_by_package('python-hello', 'amd64', self.session)
self.assertEqual([('squeeze', '2.2-1')], result)
+ def test_components(self):
+ 'test class Component'
+
+ self.assertEqual(self.loc['main'], self.comp['main'].location)
+ self.assertEqual(self.loc['contrib'], self.comp['contrib'].location)
+
if __name__ == '__main__':
unittest.main()