[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Fix and improve class Component.



Signed-off-by: Torsten Werner <twerner@debian.org>
---
 daklib/dbconn.py         |   10 +++++-----
 tests/dbtest_packages.py |    5 +++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 524f85c..1ac0c4b 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -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')),
diff --git a/tests/dbtest_packages.py b/tests/dbtest_packages.py
index f25884c..8c004cd 100755
--- a/tests/dbtest_packages.py
+++ b/tests/dbtest_packages.py
@@ -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()'
-- 
1.5.6.5



Reply to: