summaryrefslogtreecommitdiff
path: root/toxcreate.rb
diff options
context:
space:
mode:
Diffstat (limited to 'toxcreate.rb')
-rw-r--r--toxcreate.rb198
1 files changed, 78 insertions, 120 deletions
diff --git a/toxcreate.rb b/toxcreate.rb
index 9b40e0e..14e61c4 100644
--- a/toxcreate.rb
+++ b/toxcreate.rb
@@ -4,12 +4,14 @@ require 'opentox-ruby'
require 'test/unit'
require 'akephalos'
require 'capybara/dsl'
+gem 'capybara-envjs'
+require 'capybara/envjs' # gem install capybara-envjs
+# requires firefox 3.6 for akephalos and selenium !!!
Capybara.default_driver = :akephalos # use this without visual inspection
#Capybara.default_driver = :selenium # use this for visual inspection
Capybara.run_server = false
Capybara.default_wait_time = 1000
-#Capybara.javascript_driver = :selenium
-
+Capybara.javascript_driver = :envjs
class ToxCreateTest < Test::Unit::TestCase
include Capybara
@@ -18,37 +20,38 @@ class ToxCreateTest < Test::Unit::TestCase
@user = "guest"
@password = "guest"
end
-
- def teardown
- end
-
-=begin
+=begin # works only with AA enabled
def test_01_login
visit File.join(CONFIG[:services]["opentox-toxcreate"], "login")
- click_button "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_button "Login"
- puts "Login with wrong password"
- assert page.has_content?('Login failed. Please try again.')
- fill_in('Username', :with => "anonymous")
- fill_in('Password', :with => "anonymous")
- click_button "Login"
- assert page.has_content?("Welcome anonymous!")
+ click_button('Login')
+ assert page.has_content? "Login failed. Please try again."
+ fill_in('Username', :with => @user)
+ fill_in('Password', :with => @password)
+ click_button('Login')
+ assert page.has_content? "Welcome #{@user}!"
visit File.join(CONFIG[:services]["opentox-toxcreate"], "login")
- click_button "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")
assert page.has_content?('Upload training data')
- attach_file('file', "./data/hamster_carcinogenicity.mini.csv")
+ attach_file('file', "./data/hamster_carcinogenicity.csv")
+ assert page.has_button?('endpoint_list_button')
+ click_on "Select endpoint"
+ choose('EcotoxicEffects')
+ choose('Acute_toxicity_to_fish_lethality')
click_on "Create model"
assert first("h2").has_content? "hamster_carcinogenicity"
time = 0
@@ -57,119 +60,84 @@ class ToxCreateTest < Test::Unit::TestCase
time +=5
end
assert first(".model_status").has_content?("Completed")
+ sleep 5
end
-=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)
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "predict")
+ fill_in 'identifier', :with => 'NNc1ccccc1'
+ find(:xpath, '//form/fieldset[2]/input[contains(@name, "select")]').click
+ click_button("Predict")
+ click_button("Details")
+ page.has_content? "false"
+ page.has_content? "0.294"
+ page.has_content? "0.875"
+ page.has_content? "next"
end
- session = Capybara::Session.new(:akephalos)
- session.visit CONFIG[:services]["opentox-toxcreate"]
- session.click_on "Predict"
- session.fill_in "or enter a Smiles string", :with => "NNc1ccccc1"
- session.check "hamster carcinogenicity"
- session.click_button "Predict"
- assert session.has_content?("Not enough similar compounds in training dataset")
- session.click_on "Confidence"
- assert session.has_content?("Indicates the applicability domain of a model")
- session.click_button "Details"
-
- #assert page.has_content? "false"
- #assert page.has_content? "0.294"
- #assert page.has_content? "0.875"
- end
-=begin
- def test_04_inspect_policies
- Capybara.current_driver = :selenium
- 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[5]').click
- click_on "update"
- end
- sleep 5
- end
-
- def test_05_inspect_policies
- Capybara.current_driver = :selenium
- 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
- sleep 5
- end
-
- def test_06_inspect_policies
- Capybara.current_driver = :selenium
- 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"
- end
- sleep 5
end
-
- def test_07_inspect_policies
- Capybara.current_driver = :selenium
- 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
+
+ def test_04_delete_model
+ # delete the model from test_02
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "models")
+ assert (first(".model_status").has_content?("Completed") or first(".model_status").has_content?("Error"))
+ click_on "delete"
+ page.evaluate_script('window.confirm = function() { return true; }')
sleep 5
- page.evaluate_script('window.confirm = function() { return true; }')
- click_on "delete"
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"]
+ #Capybara.current_driver = :akephalos
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "create")
assert page.has_content?('Upload training data')
attach_file('file', "./data/multi_cell_call.csv")
click_on "Create model"
end
- def test_09_kazius
- Capybara.current_driver = :akephalos
+ def test_10_kazius
+ #Capybara.current_driver = :akephalos
#login(@browser, @user, @password)
- visit CONFIG[:services]["opentox-toxcreate"]
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "create")
assert page.has_content?('Upload training data')
attach_file('file', "./data/kazius.csv")
# wait until validation is completed
# check results (links, reports, results)
puts @browser.url
end
-
- def test_10_parallel_models
- #login(@browser, @user, @password)
- 10.times do
- visit CONFIG[:services]["opentox-toxcreate"]
+
+ def test_11_parallel_models
+ 5.times do
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "create")
assert page.has_content?('Upload training data')
- attach_file('file', "./data/multi_cell_call.csv")
+ attach_file('file', "./data/hamster_carcinogenicity.csv")
click_on "Create model"
end
+ while (first(".model_status").has_no_content?("Completed") and first(".model_status").has_no_content?("Error")) do
+ sleep 1
+ end
+ assert first(".model_status").has_content?("Completed")
+ end
+
+ def test_12_delete_parallel_models
+ 5.times do
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "models")
+ click_on "delete"
+ page.evaluate_script('window.confirm = function() { return true; }')
+ #sleep 5
+ end
+ sleep 5
+ visit File.join(CONFIG[:services]["opentox-toxcreate"], "models")
+ while page.has_no_content? "There are currently no models" do
+ sleep 1
+ end
+ assert page.has_content? "There are currently no models"
end
+=begin
# 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"]
@@ -186,14 +154,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