################################################################################
class DBSource(object):
- def __init__(self, maintainer = None, changedby = None):
+ def __init__(self, source = None, version = None, maintainer = None, \
+ changedby = None, poolfile = None, install_date = None):
+ self.source = source
+ self.version = version
self.maintainer = maintainer
self.changedby = changedby
+ self.poolfile = poolfile
+ self.install_date = install_date
def __repr__(self):
return '<DBSource %s (%s)>' % (self.source, self.version)
from daklib.config import Config
from daklib.dbconn import DBConn
-from sqlalchemy import create_engine, __version__
+from sqlalchemy import create_engine, func, __version__
from sqlalchemy.exc import SADeprecationWarning
from sqlalchemy.schema import DDL
self.initialize()
self.session = DBConn().session()
+ def now(self):
+ "returns the current time at the db server"
+
+ # we fetch a fresh session each time to avoid caching
+ local_session = DBConn().session()
+ current_time = local_session.query(func.now()).scalar()
+ local_session.close()
+ return current_time
+
def classes_to_clean(self):
"""
The function classes_to_clean() returns a list of classes. All objects
def setup_poolfiles(self):
'create some PoolFile objects'
+ self.setup_locations()
self.file = {}
self.file['hello'] = PoolFile(filename = 'main/h/hello/hello_2.2-2.dsc', \
location = self.loc['main'], filesize = 0, md5sum = '')
somelocation.files.append(somefile)
'''
- self.setup_locations()
+
self.setup_poolfiles()
location = self.session.query(Location)[0]
self.assertEqual('/srv/ftp-master.debian.org/ftp/pool/', location.path)
def setup_sources(self):
'create a DBSource object; but it cannot be stored in the DB yet'
- self.source = DBSource(maintainer = self.maintainer['maintainer'],
- changedby = self.maintainer['uploader'])
+ self.setup_poolfiles()
+ self.source = DBSource(source = 'hello', version = '2.2-2', \
+ maintainer = self.maintainer['maintainer'], \
+ changedby = self.maintainer['uploader'], \
+ poolfile = self.file['hello'], install_date = self.now())
def test_maintainers(self):
'''
self.assertEqual(lazyguy,
self.session.query(Maintainer).get(lazyguy.maintainer_id))
self.setup_sources()
- #TODO: needs File and Location
- #self.assertEqual(maintainer.maintains_sources, [self.source])
- #self.assertEqual(maintainer.changed_sources, [])
- #self.assertEqual(uploader.maintains_sources, [])
- #self.assertEqual(uploader.changed_sources, [self.source])
- #self.assertEqual(lazyguy.maintains_sources, [])
- #self.assertEqual(lazyguy.changed_sources, [])
+ self.assertEqual(maintainer.maintains_sources, [self.source])
+ self.assertEqual(maintainer.changed_sources, [])
+ self.assertEqual(uploader.maintains_sources, [])
+ self.assertEqual(uploader.changed_sources, [self.source])
+ self.assertEqual(lazyguy.maintains_sources, [])
+ self.assertEqual(lazyguy.changed_sources, [])
if __name__ == '__main__':
from daklib.dbconn import DBConn, Uid
-from sqlalchemy import func
import time
import unittest
TODO: Should we check all tables?
"""
- def now(self):
- "returns the current time at the db server"
-
- # we fetch a fresh session each time to avoid caching
- local_session = DBConn().session()
- current_time = local_session.query(func.now()).scalar()
- local_session.close()
- return current_time
-
def sleep(self):
time.sleep(0.001)