################################################################################
class Fingerprint(object):
- def __init__(self, *args, **kwargs):
- pass
+ def __init__(self, fingerprint = None):
+ self.fingerprint = fingerprint
def __repr__(self):
return '<Fingerprint %s>' % self.fingerprint
################################################################################
class Uid(object):
- def __init__(self, *args, **kwargs):
- pass
+ def __init__(self, uid = None, name = None):
+ self.uid = uid
+ self.name = name
def __eq__(self, val):
if isinstance(val, str):
self.assertEqual(0, q.filter(Version.version > '1.0').count())
self.assertEqual(2, q.filter(Version.version != '1.0').count())
self.assertEqual(2, q.filter(Version.version.in_(['0.5~', '1.0'])).count())
- q = self.session.query(func.min(Version.version))
- self.assertEqual('0.5~', q.one()[0])
- q = self.session.query(func.max(Version.version))
- self.assertEqual('1.0', q.one()[0])
+ q = self.session.query(func.min(Version.version).label('min'))
+ self.assertEqual('0.5~', q.one().min)
+ q = self.session.query(func.max(Version.version).label('max'))
+ self.assertEqual('1.0', q.one().max)
def tearDown(self):
self.session.close()
from db_test import DBDakTestCase
-from daklib.dbconn import Fingerprint
+from daklib.dbconn import Fingerprint, Uid
import unittest
class FingerprintTestCase(DBDakTestCase):
def test_mini(self):
- fingerprint = Fingerprint()
- fingerprint.fingerprint = 'deadbeefdeadbeef'
+ fingerprint = Fingerprint(fingerprint = 'deadbeefdeadbeef')
self.session.add(fingerprint)
- self.session.commit
query = self.session.query(Fingerprint)
self.assertEqual(1, query.count())
self.assertEqual('deadbeefdeadbeef', query.one().fingerprint)
-
- def tearDown(self):
- self.session.query(Fingerprint).delete()
- super(FingerprintTestCase, self).tearDown()
+ fingerprint.uid = Uid(uid = 'ftp-master@debian.org', name = 'ftpteam')
+ uid = self.session.query(Uid).one()
+ self.assertEqual('ftp-master@debian.org', uid.uid)
+ self.assertEqual('ftpteam', uid.name)
+ self.assertEqual(1, len(uid.fingerprint))
+ self.assertEqual('deadbeefdeadbeef', uid.fingerprint[0].fingerprint)
if __name__ == '__main__':
unittest.main()