Commit 418358bf authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Merge branch 'feature-s/2591-smart-removal' into 'dev'

Remove files only if they belong to a single sample set

Closes #2591

See merge request !859
parents 999344d5 80519c4b
Pipeline #231217 failed with stages
in 9 minutes and 21 seconds
......@@ -1023,19 +1023,27 @@ def delete():
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
sequence_file_id_sample_sets = {}
#delete data file
query = db( (db.sample_set_membership.sample_set_id == sample_set.id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.id)
for row in query :
db(db.results_file.sequence_file_id == row.id).delete()
sample_sets = get_sequence_file_sample_sets(row.id)
sequence_file_id_sample_sets[row.id] = sample_sets
if len(sample_sets) == 1:
db(db.results_file.sequence_file_id == row.id).delete()
#delete sequence file
query = db((db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == sample_set.id)
).select(db.sequence_file.id)
for row in query :
db(db.sequence_file.id == row.id).delete()
if not row.id in sequence_file_id_sample_sets:
sample_sets = get_sequence_file_sample_sets(row.id)
sequence_file_id_sample_sets[row.id] = sample_sets
if len(sequence_file_id_sample_sets[row.id]) == 1:
db(db.sequence_file.id == row.id).delete()
#delete patient sample_set
db(db.sample_set.id == sample_set.id).delete()
......
......@@ -16,7 +16,7 @@ class TestSampleSet < ServerTest
end
end
def go_to_list
def go_to_patients
$b.a(:class => ["button", "button_token", "patient_token"], :text => "patients").click
Watir::Wait.until(timeout: 30) {$b.execute_script("return jQuery.active") == 0}
table = $b.table(:id => "table")
......@@ -24,13 +24,21 @@ class TestSampleSet < ServerTest
table
end
def go_to_runs
$b.a(:class => ["button", "button_token", "run_token"], :text => "runs").click
Watir::Wait.until(timeout: 30) {$b.execute_script("return jQuery.active") == 0}
table = $b.table(:id => "table")
table.wait_until(&:present?)
table
end
def test_patient_001_list
table = go_to_list
table = go_to_patients
assert(table.tbody.present?)
end
def test_patient_add
table = go_to_list
table = go_to_patients
count = table.tbody.rows.count
......@@ -81,7 +89,7 @@ class TestSampleSet < ServerTest
end
def test_patient_edit
table = go_to_list
table = go_to_patients
# click edit button for first line in table
line = table.td(:text => /test patient 3/).parent
......@@ -104,13 +112,13 @@ class TestSampleSet < ServerTest
Watir::Wait.until(timeout: 30) {$b.execute_script("return jQuery.active") == 0}
table = $b.table(:id => 'table')
table.wait_until(&:present?)
table = go_to_list
table = go_to_patients
line = table.td(:class => "uid", :text => sample_set_id).parent
assert(line.td(:index => 3).text == "#edited")
end
def test_patient_delete
table = go_to_list
table = go_to_patients
count = table.tbody.rows.count
# click delete button for first line in table
......@@ -127,8 +135,39 @@ class TestSampleSet < ServerTest
assert(lines.count == count-1)
end
def test_association_set_delete
table = go_to_patients
count = table.tbody.rows.count
# click delete button for first assoc_set_1>patient
line = table.td(:text => /#set_assoc_1/).parent
line.i(:class => "icon-erase").click
delete_button = $b.button(:text => "delete")
delete_button.wait_until(&:present?)
delete_button.click
table = $b.table(:id => "table")
table.wait_until(&:present?)
lines = table.tbody.rows
assert(lines.count == count-1)
# check if assoc_set_1>run still exist
table = go_to_runs
line = table.td(:text => /#set_assoc_1/).parent
line.click
Watir::Wait.until(timeout: 30) {$b.execute_script("return jQuery.active") == 0}
# check that samples of assoc_set_1 still exist in run
table = $b.table(:id => "table")
table.wait_until(&:present?)
lines = table.tbody.rows
assert(lines.count == 1)
end
def test_patient_search
table = go_to_list
table = go_to_patients
filter = $b.text_field(:id => "db_filter_input")
filter.wait_until(&:present?)
......@@ -143,7 +182,7 @@ class TestSampleSet < ServerTest
=begin
def test_patient_autocomplete
table = go_to_list
table = go_to_patients
$b.execute_script("new VidjilAutoComplete().clearCache()")
filter = $b.text_field(:id => "db_filter_input")
......
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