Skip to content

Commit

Permalink
Merge pull request #120 from institut-de-genomique/list_error
Browse files Browse the repository at this point in the history
Functional tests for list errors
  • Loading branch information
osallou committed Jul 31, 2020
2 parents c297cb2 + 166e01e commit be2b295
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 16 deletions.
43 changes: 43 additions & 0 deletions tests/alu_list_error.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[GENERAL]
######################
### Initialization ###

db.fullname="alu.n : alu repeat element. alu.a : translation of alu.n repeats"
db.name=alu
db.type=nucleic_protein

offline.dir.name=offline/ncbi/blast/alu_tmp
dir.version=ncbi/blast/alu

frequency.update=0

### Synchronization ###

files.num.threads=1

# NCBI (download fasta)
protocol=ftp
server=ftp.ncbi.nih.gov
remote.dir=/blast/db/FASTA/foo/

release.file=
release.regexp=
release.file.compressed=

remote.files=^alu.*\.gz$

#Uncomment if you don't want to extract the data files.
#no.extract=true

local.files=^alu\.(a|n).*

## Post Process ## The files should be located in the projectfiles/process directory

db.post.process=




### Deployment ###

keep.old.version=1
46 changes: 30 additions & 16 deletions tests/biomaj_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def clean(self):
def __copy_test_bank_properties(self):
if self.bank_properties is not None:
return
self.bank_properties = ['alu', 'local', 'testhttp','directhttp']
self.bank_properties = ['alu', 'local', 'testhttp','directhttp',
'alu_list_error']
curdir = os.path.dirname(os.path.realpath(__file__))
for b in self.bank_properties:
from_file = os.path.join(curdir, b+'.properties')
Expand Down Expand Up @@ -302,26 +303,33 @@ def test_dependencies_list(self):

class TestBiomajFunctional(unittest.TestCase):

# Banks used in tests
BANKS = ['local', 'alu_list_error']

def setUp(self):
self.utils = UtilsForTest()
curdir = os.path.dirname(os.path.realpath(__file__))
BiomajConfig.load_config(self.utils.global_properties, allow_user_config=False)

#Delete all banks
b = Bank('local')
b.banks.remove({})

self.config = BiomajConfig('local')
data_dir = self.config.get('data.dir')
lock_file = os.path.join(data_dir,'local.lock')
if os.path.exists(lock_file):
os.remove(lock_file)
# Clean banks used in tests
for bank_name in self.BANKS:
# Delete all releases
b = Bank(bank_name)
b.banks.remove({})
# Delete lock files
config = BiomajConfig(bank_name)
data_dir = config.get('data.dir')
lock_file = os.path.join(data_dir, 'local.lock')
if os.path.exists(lock_file):
os.remove(lock_file)

def tearDown(self):
data_dir = self.config.get('data.dir')
lock_file = os.path.join(data_dir,'local.lock')
if os.path.exists(lock_file):
os.remove(lock_file)
# Delete lock files
for bank_name in self.BANKS:
config = BiomajConfig(bank_name)
data_dir = config.get('data.dir')
lock_file = os.path.join(data_dir,'local.lock')
if os.path.exists(lock_file):
os.remove(lock_file)
self.utils.clean()

def test_extract_release_from_file_name(self):
Expand Down Expand Up @@ -471,7 +479,7 @@ def test_update_hardlinks(self):
# Remove file
if os.path.exists(tmp_remote_file):
os.remove(tmp_remote_file)

def test_fromscratch_update(self):
"""
Try updating twice, at second time, bank should be updated (force with fromscratc)
Expand Down Expand Up @@ -858,3 +866,9 @@ def test_owner(self):
self.fail('not owner, should not be allowed')
except Exception as e:
pass

@attr('network')
def test_bank_list_error(self):
b = Bank('alu_list_error')
res = b.update()
self.assertFalse(res)

0 comments on commit be2b295

Please sign in to comment.