Commit 82ec5716 authored by mgbarrero's avatar mgbarrero

fixes on queries and readme

parent 64b1f2da
......@@ -84,14 +84,14 @@ class Database(bob.db.verification.utils.SQLiteDatabase,bob.db.verification.util
q = q.order_by(Client.id)
return list(q)
def models(self, protocol=None, groups=None):
def models(self, protocol=None, groups='eval'):
"""Returns a list of :py:class:`.Client` for the specific query by the user.
Models correspond to Clients for this database (At most one model per identity).
Keyword Parameters:
protocol
Ignored.
'A' or 'D'.
groups
The groups to which the subjects attached to the models belong ('Genuine')
......@@ -105,7 +105,11 @@ class Database(bob.db.verification.utils.SQLiteDatabase,bob.db.verification.util
#groups = self.check_parameters_for_validity(groups, "group", ('Genuine',))
# List of the clients
q = self.query(Client)
#q = self.query(Client)
if (protocol):
q = self.query(Client).join(File).join((ProtocolPurpose, File.protocolPurposes)).join(Protocol).filter(and_(Protocol.name.in_((protocol,)), ProtocolPurpose.sgroup.in_((groups,))))
else:
q = self.query(Client)
"""if groups:
q = q.filter(Client.stype.in_(groups))
else:
......
......@@ -29,6 +29,14 @@ class kboc16DatabaseTest(unittest.TestCase):
assert len(db.clients(groups='eval')) ==300
assert len(db.models()) == 300
assert len(db.models(groups='eval')) == 300
assert len(db.models(protocol = 'A', groups='eval')) == 300
assert len(db.models(protocol = 'A')) == 300
assert len(db.models(protocol = 'D', groups='eval')) == 100
assert len(db.models(protocol = 'D')) == 100
assert not u'101' in [x.id for x in db.models(protocol = 'D', groups='eval')]
assert u'1' in [x.id for x in db.models(protocol = 'D', groups='eval')]
assert u'100' in [x.id for x in db.models(protocol = 'D', groups='eval')]
def test_objects(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment