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
605ee83f
Commit
605ee83f
authored
Oct 11, 2018
by
Ryan Herbert
Browse files
init_test_db.py test_sample.rb set assoc tests
add tests that ensure set associations behave correctly when editing a sample.
parent
a10fd8aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/web2py/applications/vidjil/tests/functional/init_test_db.py
View file @
605ee83f
...
...
@@ -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 @
605ee83f
...
...
@@ -39,7 +39,7 @@ class TestSample < ServerTest
end
def
test_add
table
=
go_to_
first_
set
table
=
go_to_set
3
count
=
table
.
tbody
.
rows
.
count
...
...
@@ -84,7 +84,7 @@ class TestSample < ServerTest
end
def
test_edit
table
=
go_to_
first_
set
table
=
go_to_set
3
lines
=
table
.
tbody
.
rows
lines
[
0
].
wait_until_present
...
...
@@ -107,15 +107,73 @@ class TestSample < ServerTest
end
def
test_set_association_preservation
assert
False
$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
.
a
(
:text
=>
"#set_assoc_1"
).
parent
.
parent
.
cells
[
1
].
click
Watir
::
Wait
.
until
(
30
)
{
$b
.
execute_script
(
"return jQuery.active"
)
==
0
}
samples_table
=
$b
.
table
(
:id
=>
"table"
)
samples_table
.
wait_until_present
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
}
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
assert
F
alse
assert
f
alse
end
def
test_set_association_update
assert
False
$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
.
a
(
:text
=>
"#set_assoc_2"
).
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
.
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
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
...
...
@@ -147,12 +205,14 @@ class TestSample < ServerTest
end
def
test_run
table
=
go_to_
first_
set
table
=
go_to_set
2
$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
}
...
...
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