Commit 1d60231d authored by Mikaël Salson's avatar Mikaël Salson Committed by Vidjil Team

tests/controllers: tests deletion of sequence file only and sequence + results

parent 65dddd17
......@@ -98,9 +98,24 @@ class FileController(unittest.TestCase):
resp = upload()
self.assertEqual(resp.find('"message":"upload finished: plopapi"'), -1, "edit_form() failed")
def testConfirm(self):
def testConfirmFail(self):
resp = confirm()
self.assertTrue(resp.has_key('message'), "confirm() has returned an incomplete response")
self.assertTrue(resp.find('requested file doesn\'t exist') > -1, "confirm() should fail because file is not in DB")
def testConfirmSuccess(self):
test_file_id = db.sequence_file.insert(sampling_date="1903-02-02",
info="plop",
pcr="plop",
sequencer="plop",
producer="plop",
patient_id=fake_patient_id,
filename="babibou",
provider=user_id,
data_file = db.sequence_file.data_file.store(open("../../doc/analysis-example.vidjil", 'rb'), "babibou"))
request.vars['id'] = test_file_id
resp = confirm()
self.assertTrue(resp.has_key('message'), "confirm() fails to confirm deletion of a file")
def testDelete(self):
......@@ -111,16 +126,27 @@ class FileController(unittest.TestCase):
producer="plop",
patient_id=fake_patient_id,
filename="babibou",
provider=user_id)
provider=user_id,
data_file = open("../../doc/analysis-example.vidjil", 'rb'))
result_id = db.results_file.insert(sequence_file_id = test_file_id,
config_id = fake_config_id,
run_date = '2015-04-23 00:00:00')
self.assertTrue(db.sequence_file[test_file_id].filename == "babibou" , "file have been added")
request.vars['id'] = test_file_id
resp = delete()
self.assertTrue(db.sequence_file[test_file_id] == None , "file have been deleted")
self.assertTrue(db.sequence_file[test_file_id].data_file == None , "file only should have been deleted")
self.assertTrue(db.results_file[result_id] <> None, "result file should not have been deleted")
request.vars['delete_results'] = 'True'
resp = delete()
self.assertTrue(db.sequence_file[test_file_id] == None, "sequence entry in DB should have been deleted")
self.assertTrue(db.results_file[result_id] == None, "result file should have been deleted")
def testSequencerList(self):
resp = sequencer_list()
......
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