From 539bbc50bbbec4a1ea10b47b93dcbeeeeae24f62 Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Fri, 16 Sep 2016 12:13:47 +0200
Subject: [PATCH] [refactoring2016] Added tests for the database interfaces

---
 bob/bio/vein/database/biowave_test.py |  2 +-
 bob/bio/vein/database/database.py     |  4 ---
 bob/bio/vein/database/utfvp.py        |  2 +-
 bob/bio/vein/database/verafinger.py   |  2 +-
 bob/bio/vein/tests/test_databases.py  | 45 +++++++++++++++++++++++++++
 5 files changed, 48 insertions(+), 7 deletions(-)
 create mode 100644 bob/bio/vein/tests/test_databases.py

diff --git a/bob/bio/vein/database/biowave_test.py b/bob/bio/vein/database/biowave_test.py
index dc6d57c..4cd7f13 100644
--- a/bob/bio/vein/database/biowave_test.py
+++ b/bob/bio/vein/database/biowave_test.py
@@ -45,7 +45,7 @@ class BiowaveTestBioDatabase(BioDatabase):
 
     def objects(self, protocol=None, groups=None, purposes=None, model_ids=None, **kwargs):
         retval = self.__db.objects(protocol=protocol, groups=groups, purposes=purposes, model_ids=model_ids)
-        return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.file_id) for f in retval]
+        return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval]
 
     # the methodes are derived from:
     # bob.bio.db/bob/bio/db/database.py
diff --git a/bob/bio/vein/database/database.py b/bob/bio/vein/database/database.py
index 3a252f3..6e78633 100644
--- a/bob/bio/vein/database/database.py
+++ b/bob/bio/vein/database/database.py
@@ -17,7 +17,3 @@ class VeinBioFile(BioFile):
         VoxForge database.
         """
         super(VeinBioFile, self).__init__(client_id=client_id, path=path, file_id=file_id)
-
-        self.__f = f
-
-
diff --git a/bob/bio/vein/database/utfvp.py b/bob/bio/vein/database/utfvp.py
index fe27084..e6a6bb9 100644
--- a/bob/bio/vein/database/utfvp.py
+++ b/bob/bio/vein/database/utfvp.py
@@ -26,4 +26,4 @@ class UtfvpBioDatabase(BioDatabase):
 
         retval = self.__db.objects(groups=groups, protocol=protocol,
             purposes=purposes, model_ids=model_ids, **kwargs)
-        return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.file_id) for f in retval]
+        return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.id) for f in retval]
diff --git a/bob/bio/vein/database/verafinger.py b/bob/bio/vein/database/verafinger.py
index 5725b6e..3a88eae 100644
--- a/bob/bio/vein/database/verafinger.py
+++ b/bob/bio/vein/database/verafinger.py
@@ -44,4 +44,4 @@ class VerafingerBioDatabase(BioDatabase):
             self.low_level_group_names, self.high_level_group_names)
         retval = self.__db.objects(groups=groups, protocol=protocol,
             purposes=purposes, model_ids=model_ids, **kwargs)
-        return [VeinBioFile(client_id=f.client_id, path=f.path, file_id=f.file_id) for f in retval]
+        return [VeinBioFile(client_id=f.model_id, path=f.path, file_id=f.id) for f in retval]
diff --git a/bob/bio/vein/tests/test_databases.py b/bob/bio/vein/tests/test_databases.py
new file mode 100644
index 0000000..4e05beb
--- /dev/null
+++ b/bob/bio/vein/tests/test_databases.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 :
+# @author: Manuel Guenther <Manuel.Guenther@idiap.ch>
+# @date: Thu May 24 10:41:42 CEST 2012
+#
+# Copyright (C) 2011-2012 Idiap Research Institute, Martigny, Switzerland
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+from nose.plugins.skip import SkipTest
+
+import bob.bio.base
+from bob.bio.base.test.utils import db_available
+from bob.bio.base.test.test_database_implementations import check_database, check_database_zt
+
+
+@db_available('utfvp')
+def test_utfvp():
+    database = bob.bio.base.load_resource('utfvp', 'database', preferred_package='bob.bio.vein')
+    try:
+        check_database(database, protocol='nomLeftRing', groups=('dev', 'eval'))
+    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('verafinger')
+def test_verafinger():
+    database = bob.bio.base.load_resource('verafinger', 'database', preferred_package='bob.bio.vein')
+    try:
+        check_database(database, protocol='Fifty', groups=('dev', 'eval'))
+    except IOError as e:
+        raise SkipTest(
+            "The database could not queried; probably the db.sql3 file is missing. Here is the error: '%s'" % e)
-- 
GitLab