Commit b4e931d7 authored by Ivana CHINGOVSKA's avatar Ivana CHINGOVSKA
Browse files

added code for skipping tests if db doesnt exist

parent e74736f8
......@@ -31,9 +31,27 @@ if sys.version_info[0] < 3: authenticate_str = authenticate_str.encode('utf8')
enroll_str = 'enroll'
if sys.version_info[0] < 3: enroll_str = enroll_str.encode('utf8')
def db_available(test):
"""Decorator for detecting if OpenCV/Python bindings are available"""
from bob.io.base.test_utils import datafile
from nose.plugins.skip import SkipTest
import functools
@functools.wraps(test)
def wrapper(*args, **kwargs):
dbfile = datafile("db.sql3", __name__, None)
if os.path.exists(dbfile):
return test(*args, **kwargs)
else:
raise SkipTest("The database file '%s' is not available; did you forget to run 'bob_dbmanage.py %s create' ?" % (dbfile, 'replay'))
return wrapper
class ReplayDatabaseTest(unittest.TestCase):
"""Performs various tests on the replay attack database."""
@db_available
def test01_queryRealAccesses(self):
db = Database()
......@@ -57,6 +75,7 @@ class ReplayDatabaseTest(unittest.TestCase):
s = set(train + dev + test)
self.assertEqual(len(s), 200)
@db_available
def queryAttackType(self, protocol, N):
db = Database()
......@@ -80,30 +99,37 @@ class ReplayDatabaseTest(unittest.TestCase):
s = set(train + dev + test)
self.assertEqual(len(s), N)
@db_available
def test02_queryAttacks(self):
self.queryAttackType('grandtest', 1000)
@db_available
def test03_queryPrintAttacks(self):
self.queryAttackType('print', 200)
@db_available
def test04_queryMobileAttacks(self):
self.queryAttackType('mobile', 400)
@db_available
def test05_queryHighDefAttacks(self):
self.queryAttackType('highdef', 400)
@db_available
def test06_queryPhotoAttacks(self):
self.queryAttackType('photo', 600)
@db_available
def test07_queryVideoAttacks(self):
self.queryAttackType('video', 400)
@db_available
def test08_queryEnrollments(self):
db = Database()
......@@ -112,6 +138,7 @@ class ReplayDatabaseTest(unittest.TestCase):
for v in f:
self.assertEqual(v.get_realaccess().purpose, enroll_str)
@db_available
def test09_queryClients(self):
db = Database()
......@@ -126,66 +153,79 @@ class ReplayDatabaseTest(unittest.TestCase):
self.assertTrue(db.has_client_id(119))
self.assertFalse(db.has_client_id(120))
@db_available
def test10_queryfacefile(self):
db = Database()
o = db.objects(clients=(1,))[0]
o.facefile()
@db_available
def test11_manage_files(self):
from bob.db.base.script.dbmanage import main
self.assertEqual(main('replay files'.split()), 0)
@db_available
def test12_manage_dumplist_1(self):
from bob.db.base.script.dbmanage import main
self.assertEqual(main('replay dumplist --self-test'.split()), 0)
@db_available
def test13_manage_dumplist_2(self):
from bob.db.base.script.dbmanage import main
self.assertEqual(main('replay dumplist --class=attack --group=devel --support=hand --protocol=highdef --self-test'.split()), 0)
@db_available
def test14_manage_dumplist_client(self):
from bob.db.base.script.dbmanage import main
self.assertEqual(main('replay dumplist --client=117 --self-test'.split()), 0)
@db_available
def test15_manage_checkfiles(self):
from bob.db.base.script.dbmanage import main
self.assertEqual(main('replay checkfiles --self-test'.split()), 0)
@db_available
def test16_queryPrintVideoAttacks(self):
self.queryAttackType(('print','video'), 600)
@db_available
def test17_queryPrintVideoAttacks(self):
self.queryAttackType(('print','photo'), 600)
@db_available
def test18_queryPrintVideoAttacks(self):
self.queryAttackType(('highdef','print'), 600)
@db_available
def test19_queryPrintVideoAttacks(self):
self.queryAttackType(('highdef','video'), 600)
@db_available
def test20_queryPrintVideoAttacks(self):
self.queryAttackType(('highdef','mobile','print'), 1000)
@db_available
def test21_queryDigitalPhotoAttacks(self):
self.queryAttackType('digitalphoto', 400)
@db_available
def test22_queryPrintVideoAttacks(self):
self.queryAttackType(('digitalphoto','photo'), 600)
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