summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2011-09-16 12:45:12 +0200
committergebele <gebele@in-silico.ch>2011-09-16 12:45:12 +0200
commitdd225dba4bd23ffb1587a6e616195b4c1bbb4dfb (patch)
tree6d1d61578bcad299e372d4841b6d9918eb0cc85f
parent85d11b479994efbfd68d92163240b21675d351f9 (diff)
refresh toxcreate test 01 to 08.
-rw-r--r--toxcreate.rb113
1 files changed, 55 insertions, 58 deletions
diff --git a/toxcreate.rb b/toxcreate.rb
index 6117cb5..689b447 100644
--- a/toxcreate.rb
+++ b/toxcreate.rb
@@ -4,7 +4,8 @@ require 'opentox-ruby'
require 'test/unit'
require 'akephalos'
require 'capybara/dsl'
-require 'capybara/envjs'
+gem 'capybara-envjs'
+require 'capybara/envjs' # gem install capybara-envjs
Capybara.default_driver = :akephalos # use this without visual inspection
#Capybara.default_driver = :selenium # use this for visual inspection
@@ -25,33 +26,34 @@ class ToxCreateTest < Test::Unit::TestCase
sleep 5
end
-=begin
def test_01_login
visit File.join(CONFIG[:services]["opentox-toxcreate"], "login")
- click_on "Login"
- puts "Login without credentials"
- assert page.has_content? "Please enter username and password."
+ assert page.has_content?('User: guest')
fill_in('Username', :with => @user)
fill_in('Password', :with => @password + "nonsense")
- click_on "Login"
- puts "Login with wrong password"
- assert page.has_content? "Login failed. Please try again."
+ click_button('Login')
+ assert page.has_content? "Login failed. Please try again."
fill_in('Username', :with => @user)
fill_in('Password', :with => @password)
- click_on "Login"
+ click_button('Login')
assert page.has_content? "Welcome #{@user}!"
visit File.join(CONFIG[:services]["opentox-toxcreate"], "login")
- click_on "Login as guest"
- puts "Login as user guest"
- assert page.has_content? "Welcome guest!"
+ assert page.has_content?('User: guest')
+ fill_in('Username', :with => @user)
+ fill_in('Password', :with => @password + "nonsense")
+ click_button('Login')
+ assert page.has_content? "Login failed. Please try again."
+ click_button('Login as guest')
+ assert page.has_content? "Welcome #{@user}!"
end
-=end
+
def test_02_toxcreate # works only with akephalos
+ # create a model and check status is complete
Capybara.current_driver = :akephalos
#login(@browser, @user, @password)
- visit CONFIG[:services]["opentox-toxcreate"]
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "create")#visit CONFIG[:services]["opentox-toxcreate"]
assert page.has_content?('Upload training data')
- attach_file('file', "./data/hamster_carcinogenicity.mini.csv")
+ attach_file('file', "./data/hamster_carcinogenicity.csv")
click_on "Create model"
assert first("h2").has_content? "hamster_carcinogenicity"
time = 0
@@ -63,29 +65,30 @@ class ToxCreateTest < Test::Unit::TestCase
end
def test_03_predict
+ # predict with the model from test_02
Capybara.register_driver :akephalos do |app|
Capybara::Driver::Akephalos.new(app, :validate_scripts => false)
end
session = Capybara::Session.new(:akephalos)
- session.visit CONFIG[:services]["opentox-toxcreate"]
- session.click_on "Predict"
- session.fill_in "or enter a Name, InChI, Smiles, CAS, ...", :with => "NNc1ccccc1"
+ session.visit File.join(CONFIG[:services]["opentox-toxcreate"], "predict")#CONFIG[:services]["opentox-toxcreate"]
+ #session.click_on "Predict"
+ session.fill_in('identifier', :with => "NNc1ccccc1")
session.check "hamster_carcinogenicity"
session.click_button("Predict")
- session.click_on "Details"
- assert session.has_content? "inactive"
- #assert session.has_content? "false"
- #assert session.has_content? "0.294"
- #assert session.has_content? "0.875"
+ session.click_button("Details")
+ assert session.has_content? "false"
+ assert session.has_content? "0.294"
+ assert session.has_content? "0.875"
Capybara.reset_sessions!
end
def test_04_inspect_policies
- visit CONFIG[:services]["opentox-toxcreate"]
- click_on "Inspect"
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "models")#visit CONFIG[:services]["opentox-toxcreate"]
+ #click_on "Inspect"
assert first('h2').has_content? 'hamster_carcinogenicity'
- click_on "edit"
- click_on "manage policy"
+ click_on("edit name")
+ click_on("Cancel")
+ click_on("protect data")
within(:xpath, '//form[contains(@id, "form_policy_group_member_")]') do
find(:xpath, './/input[5]').click
click_on "update"
@@ -93,24 +96,23 @@ class ToxCreateTest < Test::Unit::TestCase
end
def test_05_inspect_policies
- visit CONFIG[:services]["opentox-toxcreate"]
- click_on "Inspect"
- assert first('h2').has_content? 'hamster_carcinogenicity'
- click_on "edit"
- click_on "manage policy"
+ #visit CONFIG[:services]["opentox-toxcreate"]
+ #click_on "Inspect"
+ #assert first('h2').has_content? 'hamster_carcinogenicity'
+ #click_on "edit"
+ #click_on "manage policy"
within(:xpath, '//form[contains(@id, "form_policy_group_member_")]') do
find(:xpath, './/input[4]').click
click_on "update"
- end
-
+ end
end
def test_06_inspect_policies
- visit CONFIG[:services]["opentox-toxcreate"]
- click_on "Inspect"
- assert first('h2').has_content? 'hamster_carcinogenicity'
- click_on "edit"
- click_on "manage policy"
+ #visit CONFIG[:services]["opentox-toxcreate"]
+ #click_on "Inspect"
+ #assert first('h2').has_content? 'hamster_carcinogenicity'
+ #click_on "edit"
+ #click_on "manage policy"
within(:xpath, '//form[contains(@id, "form_development")]') do
find(:xpath, './/input[4]').click
click_on "add"
@@ -119,21 +121,25 @@ class ToxCreateTest < Test::Unit::TestCase
end
def test_07_inspect_policies
- visit CONFIG[:services]["opentox-toxcreate"]
- click_on "Inspect"
- assert first('h2').has_content? 'hamster_carcinogenicity'
- click_on "edit"
- click_on "manage policy"
+ #visit CONFIG[:services]["opentox-toxcreate"]
+ #click_on "Inspect"
+ #assert first('h2').has_content? 'hamster_carcinogenicity'
+ #click_on "edit"
+ #click_on "manage policy"
within(:xpath, '//form[contains(@id, "form_policy_group_development_")]') do
find(:xpath, './/input[3]').click
click_on "update"
end
sleep 5
#page.evaluate_script('window.confirm = function() { return true; }')
+ click_on "exit"
+ end
+
+ def test_08_delete_model
click_on "delete"
- end
+ end
=begin
- def test_08_multi_cell_call
+ def test_09_multi_cell_call
#login(@browser, @user, @password)
Capybara.current_driver = :akephalos
visit CONFIG[:services]["opentox-toxcreate"]
@@ -142,7 +148,7 @@ class ToxCreateTest < Test::Unit::TestCase
click_on "Create model"
end
- def test_09_kazius
+ def test_10_kazius
Capybara.current_driver = :akephalos
#login(@browser, @user, @password)
visit CONFIG[:services]["opentox-toxcreate"]
@@ -153,7 +159,7 @@ class ToxCreateTest < Test::Unit::TestCase
puts @browser.url
end
- def test_10_parallel_models
+ def test_11_parallel_models
#login(@browser, @user, @password)
10.times do
visit CONFIG[:services]["opentox-toxcreate"]
@@ -163,7 +169,7 @@ class ToxCreateTest < Test::Unit::TestCase
end
end
# raises capybara errors, but gui works from browser
- def test_11_toxcreate_sdf # works only with akephalos
+ def test_12_toxcreate_sdf # works only with akephalos
Capybara.current_driver = :akephalos
#login(@browser, @user, @password)
visit CONFIG[:services]["opentox-toxcreate"]
@@ -180,13 +186,4 @@ class ToxCreateTest < Test::Unit::TestCase
end
=end
-
-=begin
- def login(browser, user, password)
- browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login")
- browser.text_field(:id, "username").set(user)
- browser.text_field(:id, "password").set(password)
- browser.button(:value, "Login").click
- end
-=end
end