From: Torsten Werner Date: Sat, 12 Feb 2011 21:24:09 +0000 (+0100) Subject: Fix and improve class Component. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=227db2f1b21c06ec076c88f79850daf0f154b900;p=dak Fix and improve class Component. Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 524f85c8..1ac0c4b5 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 f25884ce..8c004cd6 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()'