Commit 00ba154e authored by Ryan Herbert's avatar Ryan Herbert

init_test_db.py test_tag.py add tests for tags

parent de2427a3
Pipeline #35881 failed with stages
in 6 minutes and 26 seconds
......@@ -57,10 +57,13 @@ class DBInitialiser(object):
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(5):
tag_id = db.tag.insert(name="test%d" % i)
db.group_tag.insert(group_id=public_group.id, tag_id=tag_id)
for t in types:
ssid = db.sample_set.insert(sample_type=t)
sid = db[t].insert(**self.get_set_dict(t, ssid, i))
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)
self.initialised_sets = True
@_needs_init
......@@ -76,15 +79,17 @@ class DBInitialiser(object):
sample_sets = db(db.sample_set.id > 0).select()
for sample_set in sample_sets:
for i in range(3):
tag_id = db(db.tag.name == "test%d" % i).select().first().id
sfid = db.sequence_file.insert(
sampling_date="2010-10-10",
info="test file %s %d" % (sample_set.sample_type, i),
info="test file %s %d #test%d" % (sample_set.sample_type, i, i),
filename="test_file.fasta",
size_file=1024,
network=False,
data_file="test_sequence_file"
)
db.sample_set_membership.insert(sample_set_id=sample_set.id, sequence_file_id=sfid)
db.tag_ref.insert(tag_id=tag_id, table_name=db.sequence_file, record_id=sfid)
@_needs_files
def _init_results_files(self):
......@@ -100,14 +105,16 @@ class DBInitialiser(object):
sequence_file_id=sf.id,
config_id=config.id,
run_date="2010-10-10 10:10:10:10",
scheduler_task_id=stid
scheduler_task_id=stid,
data_file="test_results_file"
)
db.fused_file.insert(
config_id=config.id,
sample_set_id=membership.sample_set_id,
fuse_date="2010-10-10 10:10:10:10",
status="COMPLETED",
sequence_file_list="%d_" % membership.sequence_file_id
sequence_file_list="%d_" % membership.sequence_file_id,
fused_file="test_fused_file"
)
@_needs_init
......
load 'vidjil_browser.rb'
load 'browser_test.rb'
class TestTag < BrowserTest
def setup
super
if not defined? $b
set_browser("http://localhost/browser")
end
login_form = $b.form(:id => 'login_form')
if login_form.present?
login_form.text_field(:id => "auth_user_email").set('plop@plop.com')
login_form.text_field(:id => "auth_user_password").set('foobartest')
login_form.tr(:id => 'submit_record__row').input(:type => 'submit').click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
end
end
def go_to_list
#$b.a(:class => ["button", "button_token", "patient_token"], :text => "patients").click
$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 test_click_sample_set
table = go_to_list
table.a(:text => /#test2/).click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.table(:id => "table").tbody.rows.each do |row|
assert(row.a(:text => /#test2/).present?)
end
end
def test_click_sample
table = go_to_list
table.td(:text => /test patient 2/).click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
table.tbody.a(:text => "#test2").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
table = $b.table(:id => "table")
table.tbody.a(:text => "#test2").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.table(:id => "table").tbody.rows.each do |row|
assert(row.a(:text => /#test2/).present?)
end
end
def test_search_sample_set
table = go_to_list
search = $b.text_field(:id => "db_filter_input")
search.set("#test2")
search.fire_event('onchange')
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.table(:id => "table").tbody.rows.each do |row|
assert(row.a(:text => "#test2").present?)
end
end
def test_search_sample
table = go_to_list
$b.span(:class => "button2", :text => "compare samples/patients").click
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
search = $b.text_field(:id => "db_filter_input")
search.set("#test2")
search.fire_event('onchange')
Watir::Wait.until(30) {$b.execute_script("return jQuery.active") == 0}
$b.table(:id => "table").tbody.rows.each do |row|
assert(row.a(:text => /#test2/).present?)
end
end
end
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