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

Added check for existing protocol directory

parent 90e2ea05
Pipeline #6689 passed with stages
in 5 minutes and 34 seconds
......@@ -229,7 +229,12 @@ class FileListBioDatabase(ZTBioDatabase):
def _list_reader(self, protocol):
if protocol not in self.list_readers:
if protocol is not None:
protocol_dir = os.path.join(self.get_base_directory(), protocol)
if not os.path.isdir(protocol_dir):
raise ValueError("The directory %s for the given protocol '%s' does not exist" % (protocol_dir, protocol))
self.list_readers[protocol] = ListReader(self.keep_read_lists_in_memory)
return self.list_readers[protocol]
def _make_bio(self, files):
......
......@@ -22,6 +22,7 @@
import os
import bob.io.base.test_utils
from bob.bio.base.database import FileListBioDatabase
import nose.tools
example_dir = os.path.realpath(bob.io.base.test_utils.datafile('.', __name__, 'data/example_filelist'))
......@@ -124,6 +125,8 @@ def test_query_protocol():
assert db.client_id_from_model_id('6', group=None) == '6'
assert db.client_id_from_t_model_id('7', group=None) == '7'
nose.tools.assert_raises(ValueError, db.objects, protocol='non-existent')
def test_query_dense():
db = FileListBioDatabase(example_dir, 'test', probes_filename='for_probes.lst')
......@@ -162,13 +165,7 @@ def test_multiple_extensions():
assert file_name == os.path.join(example_dir, file.path + '.pos')
file = bob.bio.base.database.BioFile(4, "data/model4_session1_sample1", "data/model4_session1_sample1")
try:
file_name = db.original_file_name(file, False)
raised = False
except IOError as e:
raised = True
assert raised
nose.tools.assert_raises(IOError, db.original_file_name, file, False)
def test_driver_api():
......
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