]> err.no Git - dak/commitdiff
Add a test for PoolFile and Location.
authorTorsten Werner <twerner@debian.org>
Wed, 19 Jan 2011 07:39:42 +0000 (08:39 +0100)
committerTorsten Werner <twerner@debian.org>
Wed, 19 Jan 2011 07:39:42 +0000 (08:39 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py
tests/dbtest_packages.py

index 06b20c38e61489804185d1dcfb0e9f162e356142..b46eede790c80edbd8759cd8bbdf64b8709a22d9 100755 (executable)
@@ -1070,8 +1070,12 @@ __all__.append('get_dscfiles')
 ################################################################################
 
 class PoolFile(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, filename = None, location = None, filesize = -1, \
+        md5sum = None):
+        self.filename = filename
+        self.location = location
+        self.filesize = filesize
+        self.md5sum = md5sum
 
     def __repr__(self):
         return '<PoolFile %s>' % self.filename
@@ -1522,8 +1526,10 @@ __all__.append('get_dbchange')
 ################################################################################
 
 class Location(object):
-    def __init__(self, *args, **kwargs):
-        pass
+    def __init__(self, path = None):
+        self.path = path
+        # the column 'type' should go away, see comment at mapper
+        self.archive_type = 'pool'
 
     def __repr__(self):
         return '<Location %s (%s)>' % (self.path, self.location_id)
index deca4812d3bc08ac6a158f30ad1f100432103ba4..c06d9442180121b3040d9f7d646aa25b9b524ac2 100755 (executable)
@@ -3,7 +3,7 @@
 from db_test import DBDakTestCase
 
 from daklib.dbconn import Architecture, Suite, get_suite_architectures, \
-    get_architecture_suites, Maintainer, DBSource
+    get_architecture_suites, Maintainer, DBSource, Location, PoolFile
 
 import unittest
 
@@ -90,6 +90,35 @@ class PackageTestCase(DBDakTestCase):
         self.assertEqual(2, len(suites))
         self.assertTrue(self.suite['lenny'] not in suites)
 
+    def setup_locations(self):
+        'create some Location objects, TODO: add component'
+
+        self.loc = {}
+        self.loc['main'] = Location(path = \
+            '/srv/ftp-master.debian.org/ftp/pool/')
+        self.session.add(self.loc['main'])
+
+    def setup_poolfiles(self):
+        'create some PoolFile objects'
+
+        self.file = {}
+        self.file['hello'] = PoolFile(filename = 'main/h/hello/hello_2.2-2.dsc', \
+            location = self.loc['main'], filesize = 0, md5sum = '')
+        self.file['sl'] = PoolFile(filename = 'main/s/sl/sl_3.03-16.dsc', \
+            location = self.loc['main'], filesize = 0, md5sum = '')
+        self.session.add_all(self.file.values())
+
+    def test_poolfiles(self):
+        self.setup_locations()
+        self.setup_poolfiles()
+        location = self.session.query(Location)[0]
+        self.assertEqual('/srv/ftp-master.debian.org/ftp/pool/', location.path)
+        self.assertEqual(2, location.files.count())
+        poolfile = location.files. \
+                filter(PoolFile.filename.like('%/hello/hello%')).one()
+        self.assertEqual('main/h/hello/hello_2.2-2.dsc', poolfile.filename)
+        self.assertEqual(location, poolfile.location)
+
     def setup_maintainers(self):
         'create some Maintainer objects'