Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
b6736c74
Commit
b6736c74
authored
Oct 12, 2018
by
Mathieu Giraud
Browse files
Merge branch 'feature-s/3489-fix-multi-upload-edit' into 'dev'
Feature s/3489 fix multi upload edit See merge request
!300
parents
89e58b08
bcc76655
Pipeline
#43989
failed with stages
in 49 minutes and 59 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
server/web2py/applications/vidjil/controllers/file.py
View file @
b6736c74
...
...
@@ -48,7 +48,9 @@ def link_to_sample_sets(seq_file_id, id_dict):
Create sample set memberships and return a dict of the sample set ids.
The keys to the dict are thee same as the ones passed in id_dict
'''
log
.
debug
(
"linking file %d to sets:"
%
seq_file_id
)
for
key
in
id_dict
:
log
.
debug
(
"%s: %s"
%
(
key
,
str
(
id_dict
[
key
])))
arr
=
[{
'sample_set_id'
:
oid
,
'sequence_file_id'
:
seq_file_id
}
for
oid
in
id_dict
[
key
]]
db
.
sample_set_membership
.
bulk_insert
(
arr
)
db
.
commit
()
...
...
server/web2py/applications/vidjil/tests/functional/init_test_db.py
View file @
b6736c74
...
...
@@ -16,6 +16,7 @@ class DBInitialiser(object):
self
.
_init_sequence_files
()
self
.
_init_results_files
()
self
.
_init_notifications
()
self
.
_init_set_association_data
()
def
_needs_init
(
func
):
...
...
@@ -135,5 +136,32 @@ class DBInitialiser(object):
c
=
db
.
auth_group
.
insert
(
role
=
"test child %d"
%
i
)
db
.
group_assoc
.
insert
(
first_group_id
=
parent
,
second_group_id
=
c
)
@
_needs_init
def
_init_set_association_data
(
self
):
types
=
[
defs
.
SET_TYPE_PATIENT
,
defs
.
SET_TYPE_RUN
,
defs
.
SET_TYPE_GENERIC
]
public_group
=
db
(
db
.
auth_group
.
role
==
"public"
).
select
().
first
()
for
i
in
range
(
3
):
tag_id
=
db
.
tag
.
insert
(
name
=
"set_assoc_%d"
%
i
)
db
.
group_tag
.
insert
(
group_id
=
public_group
.
id
,
tag_id
=
tag_id
)
sfid
=
db
.
sequence_file
.
insert
(
sampling_date
=
"2010-10-10"
,
info
=
"#set_assoc_%d"
%
i
,
filename
=
"test_file.fasta"
,
size_file
=
1024
,
network
=
False
,
data_file
=
"test_sequence_file"
)
db
.
tag_ref
.
insert
(
tag_id
=
tag_id
,
table_name
=
db
.
sequence_file
,
record_id
=
sfid
)
for
t
in
types
:
ssid
=
db
.
sample_set
.
insert
(
sample_type
=
t
)
d
=
self
.
get_set_dict
(
t
,
ssid
,
i
)
d
[
'info'
]
=
"set association test #set_assoc_%d"
%
i
sid
=
db
[
t
].
insert
(
**
d
)
auth
.
add_permission
(
public_group
.
id
,
PermissionEnum
.
access
.
value
,
db
.
sample_set
,
ssid
)
db
.
tag_ref
.
insert
(
tag_id
=
tag_id
,
table_name
=
t
,
record_id
=
sid
)
db
.
sample_set_membership
.
insert
(
sample_set_id
=
ssid
,
sequence_file_id
=
sfid
)
initialiser
=
DBInitialiser
()
initialiser
.
run
()
server/web2py/applications/vidjil/tests/functional/test_sample.rb
View file @
b6736c74
...
...
@@ -21,12 +21,17 @@ class TestSample < ServerTest
go_to_set
0
end
def
go_to_
set
(
index
)
def
go_to_
patient_list
# load patient list
$b
.
a
(
:class
=>
"button button_token patient_token"
,
:text
=>
"patients"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
table
=
$b
.
table
(
:id
=>
"table"
)
table
.
wait_until_present
table
end
def
go_to_set
(
index
)
table
=
go_to_patient_list
lines
=
table
.
tbody
.
rows
lines
[
index
].
wait_until_present
# select first patient
...
...
@@ -38,8 +43,18 @@ class TestSample < ServerTest
table
end
def
go_to_set_by_tag
(
tag
)
table
=
go_to_patient_list
table
.
a
(
:text
=>
tag
).
parent
.
parent
.
cells
[
2
].
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
samples_table
=
$b
.
table
(
:id
=>
"table"
)
samples_table
.
wait_until_present
samples_table
end
def
test_add
table
=
go_to_
first_set
table
=
go_to_
set_by_tag
"#test4"
count
=
table
.
tbody
.
rows
.
count
...
...
@@ -84,7 +99,7 @@ class TestSample < ServerTest
end
def
test_edit
table
=
go_to_
first_set
table
=
go_to_
set_by_tag
"#test3"
lines
=
table
.
tbody
.
rows
lines
[
0
].
wait_until_present
...
...
@@ -106,8 +121,120 @@ class TestSample < ServerTest
assert
(
$b
.
link
(
:text
=>
"#edited"
).
present?
)
end
def
test_set_association_preservation
samples_table
=
go_to_set_by_tag
"#set_assoc_1"
samples_table
.
a
(
:text
=>
"#set_assoc_1"
).
parent
.
parent
.
i
(
:class
=>
"icon-pencil-2"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
assert
(
form
.
div
(
:id
=>
'set_div'
).
spans
.
length
==
3
)
sets_text
=
form
.
input
(
:id
=>
"file_set_list"
).
text
form
.
text_field
(
:id
=>
"file_info_0"
).
set
(
"#set_assoc_1 #edited"
)
form
.
input
(
:type
=>
"submit"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
samples_table
.
a
(
:text
=>
"#set_assoc_1"
).
parent
.
parent
.
i
(
:class
=>
"icon-pencil-2"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
assert
(
form
.
div
(
:id
=>
'set_div'
).
spans
.
length
==
3
)
assert
(
sets_text
==
form
.
input
(
:id
=>
"file_set_list"
).
text
)
end
def
test_set_association_create
$b
.
a
(
:class
=>
"button button_token patient_token"
,
:text
=>
"patients"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
table
=
$b
.
table
(
:id
=>
"table"
)
table
.
wait_until_present
patient_id
=
table
.
a
(
:text
=>
"#set_assoc_0"
).
parent
.
parent
.
cells
[
0
].
text
$b
.
a
(
:class
=>
"button button_token run_token"
,
:text
=>
"runs"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
table
=
$b
.
table
(
:id
=>
"table"
)
table
.
wait_until_present
run_id
=
table
.
a
(
:text
=>
"#set_assoc_0"
).
parent
.
parent
.
cells
[
0
].
text
$b
.
a
(
:class
=>
"button button_token generic_token"
,
:text
=>
"sets"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
table
=
$b
.
table
(
:id
=>
"table"
)
table
.
wait_until_present
set_id
=
table
.
a
(
:text
=>
"#set_assoc_0"
).
parent
.
parent
.
cells
[
0
].
text
samples_table
=
go_to_set_by_tag
"#set_assoc_0"
$b
.
span
(
:class
=>
"button2"
,
:text
=>
"+ add samples"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
$b
.
input
(
:id
=>
"source_nfs"
).
click
jstree
=
$b
.
div
(
:id
=>
"jstree"
)
$b
.
div
(
:id
=>
"jstree_field_0"
).
span
(
:text
=>
"browse"
).
click
assert
(
jstree
.
visible?
)
jstree_file
=
jstree
.
a
(
:id
=>
"//Demo-X5.fa_anchor"
)
unless
jstree_file
.
present?
and
jstree_file
.
present?
jstree
.
a
(
:id
=>
"/_anchor"
).
double_click
end
jstree_file
.
wait_until_present
jstree_file
.
click
$b
.
span
(
:id
=>
"jstree_button"
).
click
assert
(
!
jstree
.
visible?
)
form
.
text_field
(
:id
=>
"file_sampling_date_0"
).
set
(
"2010-10-10"
)
form
.
text_field
(
:id
=>
"file_info_0"
).
set
(
"#my_file_add"
)
val
=
":p 0 (2010-10-10) (
#{
patient_id
}
)|:r run 0 (
#{
run_id
}
)|:s generic 0 (
#{
set_id
}
)"
$b
.
execute_script
(
"return $('#file_set_list').val('
#{
val
}
');"
)
form
.
input
(
:type
=>
"submit"
).
click
samples_table
=
$b
.
table
(
:id
=>
"table"
)
samples_table
.
wait_until_present
samples_table
.
a
(
:text
=>
"#set_assoc_0"
).
parent
.
parent
.
i
(
:class
=>
"icon-pencil-2"
).
click
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
set_div
=
form
.
div
(
:id
=>
'set_div'
)
assert
(
set_div
.
spans
.
length
==
3
)
end
def
test_set_association_update
samples_table
=
go_to_set_by_tag
"#set_assoc_2"
samples_table
.
a
(
:text
=>
"#set_assoc_2"
).
parent
.
parent
.
i
(
:class
=>
"icon-pencil-2"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
set_div
=
form
.
div
(
:id
=>
'set_div'
)
assert
(
set_div
.
spans
.
length
==
3
)
set_div
.
spans
[
1
].
i
(
:class
=>
"icon-cancel"
).
click
form
.
input
(
:type
=>
"submit"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
samples_table
=
$b
.
table
(
:id
=>
"table"
)
samples_table
.
wait_until_present
samples_table
.
a
(
:text
=>
"#set_assoc_2"
).
parent
.
parent
.
i
(
:class
=>
"icon-pencil-2"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
form
=
$b
.
form
(
:id
=>
"upload_form"
)
form
.
wait_until_present
set_div
=
form
.
div
(
:id
=>
'set_div'
)
assert
(
set_div
.
spans
.
length
==
2
)
end
def
test_delete
table
=
go_to_set
3
table
=
go_to_set
_by_tag
"#test2"
count
=
table
.
tbody
.
rows
.
count
...
...
@@ -135,12 +262,14 @@ class TestSample < ServerTest
end
def
test_run
table
=
go_to_
first_set
table
=
go_to_
set_by_tag
"#set_assoc_0"
$b
.
select_list
(
:id
=>
"choose_config"
).
select_value
(
2
)
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
lines
=
table
.
tbody
.
rows
samples_table
=
$b
.
table
(
:id
=>
"table"
)
samples_table
.
wait_until_present
lines
=
samples_table
.
tbody
.
rows
lines
[
0
].
wait_until_present
lines
[
0
].
i
(
:class
=>
"icon-cog-2"
).
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
...
...
server/web2py/applications/vidjil/views/file/form.html
View file @
b6736c74
...
...
@@ -54,7 +54,7 @@
id=
"file_set_list"
name=
"set_ids"
type=
"text"
value=
"{{="
,
".
join
([
set
['
id
']
for
set
in
sets
])}}"
>
value=
"{{="
|
".
join
([
set
['
id
']
for
set
in
sets
])}}"
>
<div
id=
"set_div"
class=
"token_container"
data-min-tokens=
1
>
{{ for set in sets: }}
<span
class=
"set_token {{=set['type']}}_token"
data-set-id=
"{{=set['id']}}"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment