Commit 57054df0 authored by Manuel Günther's avatar Manuel Günther
Browse files

Skipping tests when db file is not available

parent 728b35ce
......@@ -22,10 +22,27 @@
import os, sys
import bob.db.banca
db = bob.db.banca.Database()
def db_available(test):
"""Decorator for detecting if OpenCV/Python bindings are available"""
from import datafile
from nose.plugins.skip import SkipTest
import functools
def wrapper(*args, **kwargs):
dbfile = datafile("db.sql3", __name__, None)
if os.path.exists(dbfile):
return test(*args, **kwargs)
raise SkipTest("The database file '%s' is not available; did you forget to run ' %s create' ?" % (dbfile, 'banca'))
return wrapper
def test_clients():
# test whether the correct number of clients is returned
db = bob.db.banca.Database()
assert len(db.groups()) == 3
assert len(db.clients()) == 82
assert len(db.clients(groups='world')) == 30
......@@ -40,9 +57,10 @@ def test_clients():
assert len(db.clients(genders='m')) == 41
def test_objects():
# tests if the right number of File objects is returned
db = bob.db.banca.Database()
assert len(db.objects()) == 6540
assert len(db.objects(groups='world')) == 300
assert len(db.objects(groups='world', subworld='onethird')) == 100
......@@ -69,9 +87,10 @@ def test_objects():
assert len(db.zobjects(groups=group, model_ids=model_id)) == 105
def test_annotations():
# Tests that for all files the annotated eye positions exist and are in correct order
db = bob.db.banca.Database()
for f in db.objects():
annotations = db.annotations(
assert annotations is not None
......@@ -84,8 +103,9 @@ def test_annotations():
assert annotations['leye'][1] > annotations['reye'][1]
def test_driver_api():
# Tests the driver API
from bob.db.base.script.dbmanage import main
assert main('banca dumplist --self-test'.split()) == 0
assert main('banca dumplist --protocol=P --class=client --group=dev --purpose=enrol --model-id=1008 --self-test'.split()) == 0
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