]> err.no Git - dak/commitdiff
Fix and improve class Component.
authorTorsten Werner <twerner@debian.org>
Sat, 12 Feb 2011 21:24:09 +0000 (22:24 +0100)
committerTorsten Werner <twerner@debian.org>
Sat, 12 Feb 2011 21:24:09 +0000 (22:24 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_packages.py

index 524f85c83816f0400323e488760eb659fdb3bfe6..1ac0c4b5de02992a83819ef8e02999369582d701 100755 (executable)
@@ -911,8 +911,8 @@ class Component(ORMObject):
         return NotImplemented
 
     def properties(self):
-        return ['component_name', 'component_id', 'description', 'location', \
-            'meets_dfsg']
+        return ['component_name', 'component_id', 'description', \
+            'location_count', 'meets_dfsg', 'overrides_count']
 
     def not_null_constraints(self):
         return ['component_name']
@@ -3144,8 +3144,7 @@ class DBConn(object):
         mapper(Location, self.tbl_location,
                properties = dict(location_id = self.tbl_location.c.id,
                                  component_id = self.tbl_location.c.component,
-                                 component = relation(Component, \
-                                     backref=backref('location', uselist = False)),
+                                 component = relation(Component, backref='location'),
                                  archive_id = self.tbl_location.c.archive,
                                  archive = relation(Archive),
                                  # FIXME: the 'type' column is old cruft and
@@ -3169,7 +3168,8 @@ class DBConn(object):
                                  suite = relation(Suite),
                                  package = self.tbl_override.c.package,
                                  component_id = self.tbl_override.c.component,
-                                 component = relation(Component),
+                                 component = relation(Component, \
+                                    backref=backref('overrides', lazy='dynamic')),
                                  priority_id = self.tbl_override.c.priority,
                                  priority = relation(Priority, \
                                     backref=backref('overrides', lazy='dynamic')),
index f25884cebd95ddaed938cccdee0a46185c0f9bbd..8c004cd61fba12f0fa893b618e9e00a36732a738 100755 (executable)
@@ -370,8 +370,9 @@ class PackageTestCase(DBDakTestCase):
     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)
+        self.assertEqual([self.loc['main']], self.comp['main'].location)
+        self.assertEqual([self.loc['contrib']], self.comp['contrib'].location)
+        self.assertEqual(0, self.comp['main'].overrides.count())
 
     def test_get_component_by_package_suite(self):
         'test get_component_by_package_suite()'