Commit d3859cf5 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

[refactoring2016] Added more tests

parent 12bbf122
Pipeline #3742 passed with stages
in 49 minutes and 46 seconds
......@@ -18,47 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from nose.plugins.skip import SkipTest
import bob.bio.base
from bob.bio.base.test.utils import db_available
def _check_database(database, groups=('dev',), protocol=None, training_depends=False, models_depend=False):
assert isinstance(database, bob.bio.base.database.BioDatabase)
# load the directories
if 'HOME' in os.environ:
database.replace_directories(os.path.join(os.environ['HOME'], '.bob_bio_databases.txt'))
if protocol: database.protocol = protocol
if protocol is None: protocol = database.protocol
assert len(database.all_files()) > 0
assert len(database.training_files('train_extractor')) > 0
assert len(database.arrange_by_client(database.training_files('train_enroller'))) > 0
for group in groups:
model_ids = database.model_ids_with_protocol(group, protocol=protocol)
assert len(model_ids) > 0
assert database.client_id_from_model_id(model_ids[0]) is not None
assert len(database.enroll_files(model_ids[0], group)) > 0
assert len(database.probe_files(model_ids[0], group)) > 0
assert database.training_depends_on_protocol == training_depends
assert database.models_depend_on_protocol == models_depend
def _check_database_zt(database, groups=('dev', 'eval'), protocol=None, training_depends=False, models_depend=False):
_check_database(database, groups, protocol, training_depends, models_depend)
assert isinstance(database, bob.bio.base.database.ZTBioDatabase)
for group in groups:
t_model_ids = database.t_model_ids(group)
assert len(t_model_ids) > 0
assert database.client_id_from_model_id(t_model_ids[0]) is not None
assert len(database.t_enroll_files(t_model_ids[0], group)) > 0
assert len(database.z_probe_files(group)) > 0
from bob.bio.base.test.test_database_implementations import check_database, check_database_zt
def _check_annotations(database):
......@@ -74,7 +38,18 @@ def _check_annotations(database):
def test_arface():
database = bob.bio.base.load_resource('arface', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, groups=('dev', 'eval'))
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('atnt')
def test_atnt():
database = bob.bio.base.load_resource('atnt', 'database', preferred_package='bob.bio.face')
try:
check_database(database)
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -85,7 +60,7 @@ def test_arface():
def test_banca():
database = bob.bio.base.load_resource('banca', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database)
check_database_zt(database)
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -96,8 +71,8 @@ def test_banca():
def test_caspeal():
database = bob.bio.base.load_resource('caspeal', 'database', preferred_package='bob.bio.face')
try:
_check_database(database)
_check_database(database, protocol='aging')
check_database(database)
check_database(database, protocol='aging')
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -116,14 +91,35 @@ def test_caspeal():
# raise SkipTest(
# "The database could not be opened, probably the original directory is wrong. Here is the error: '%s'" % e)
@db_available('cuhk_cufs')
def test_cuhk_cufs():
database = bob.bio.base.load_resource('cuhk_cufs', 'database', preferred_package='bob.bio.face')
try:
check_database(database)
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('gbu')
def test_gbu():
database = bob.bio.base.load_resource('gbu', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, models_depend=True)
_check_database(database, protocol='Bad', models_depend=True)
_check_database(database, protocol = 'Ugly', models_depend=True)
check_database(database, models_depend=True)
check_database(database, protocol='Bad', models_depend=True)
check_database(database, protocol = 'Ugly', models_depend=True)
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('ijba')
def test_ijba():
database = bob.bio.base.load_resource('ijba', 'database', preferred_package='bob.bio.face')
try:
check_database(database)
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -134,10 +130,10 @@ def test_gbu():
def test_lfw():
database = bob.bio.base.load_resource('lfw-restricted', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, training_depends=True, models_depend=True)
_check_database(database, groups=('dev', 'eval'), protocol='fold1', training_depends=True, models_depend=True)
_check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_package='bob.bio.face'),
training_depends=True, models_depend=True)
check_database(database, training_depends=True, models_depend=True)
check_database(database, groups=('dev', 'eval'), protocol='fold1', training_depends=True, models_depend=True)
check_database(bob.bio.base.load_resource('lfw-unrestricted', 'database', preferred_package='bob.bio.face'),
training_depends=True, models_depend=True)
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -148,12 +144,12 @@ def test_lfw():
def test_mobio():
database = bob.bio.base.load_resource('mobio-image', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database, models_depend=True)
_check_database_zt(database, protocol='female', models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-male', 'database', preferred_package='bob.bio.face'),
models_depend=True)
_check_database_zt(bob.bio.base.load_resource('mobio-female', 'database', preferred_package='bob.bio.face'),
models_depend=True)
check_database_zt(database, models_depend=True)
check_database_zt(database, protocol='female', models_depend=True)
check_database_zt(bob.bio.base.load_resource('mobio-male', 'database', preferred_package='bob.bio.face'),
models_depend=True)
check_database_zt(bob.bio.base.load_resource('mobio-female', 'database', preferred_package='bob.bio.face'),
models_depend=True)
except IOError as e:
raise SkipTest(
"The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
......@@ -169,9 +165,9 @@ def test_mobio():
def test_multipie():
database = bob.bio.base.load_resource('multipie', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database, training_depends=True)
_check_database_zt(bob.bio.base.load_resource('multipie-pose', 'database', preferred_package='bob.bio.face'),
training_depends=True)
check_database_zt(database, training_depends=True)
check_database_zt(bob.bio.base.load_resource('multipie-pose', 'database', preferred_package='bob.bio.face'),
training_depends=True)
except IOError as e:
raise SkipTest(
"The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
......@@ -190,7 +186,7 @@ def test_multipie():
def test_scface():
database = bob.bio.base.load_resource('scface', 'database', preferred_package='bob.bio.face')
try:
_check_database_zt(database)
check_database_zt(database)
_check_annotations(database)
except IOError as e:
raise SkipTest(
......@@ -201,8 +197,19 @@ def test_scface():
def test_xm2vts():
database = bob.bio.base.load_resource('xm2vts', 'database', preferred_package='bob.bio.face')
try:
_check_database(database, groups=('dev', 'eval'))
_check_database(database, groups=('dev', 'eval'), protocol='darkened-lp1')
check_database(database, groups=('dev', 'eval'))
check_database(database, groups=('dev', 'eval'), protocol='darkened-lp1')
_check_annotations(database)
except IOError as e:
raise SkipTest(
"The database could not be queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
@db_available('replay')
def test_replay():
database = bob.bio.base.load_resource('replay', 'database', preferred_package='bob.bio.face')
try:
check_database(database, groups=('dev', 'eval'))
_check_annotations(database)
except IOError as e:
raise SkipTest(
......
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