From f30994581b5eb41ef40771ffd74b4bb9a55b2f06 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 5 Oct 2011 10:30:35 +0200 Subject: with parallel models test --- toxcreate.rb | 98 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/toxcreate.rb b/toxcreate.rb index 689b447..13ecf77 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -6,7 +6,7 @@ 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 @@ -21,11 +21,12 @@ class ToxCreateTest < Test::Unit::TestCase @password = "guest" end - def teardown + #def teardown #puts Time.now.localtime.strftime("%Y-%m-%d %H:%M:%S") - sleep 5 - end - + #sleep 5 + #time +=5 + #end + def test_01_login visit File.join(CONFIG[:services]["opentox-toxcreate"], "login") assert page.has_content?('User: guest') @@ -51,7 +52,7 @@ class ToxCreateTest < Test::Unit::TestCase # create a model and check status is complete Capybara.current_driver = :akephalos #login(@browser, @user, @password) - visit File.join(CONFIG[:services]["opentox-toxcreate"], "create")#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.csv") click_on "Create model" @@ -70,7 +71,7 @@ class ToxCreateTest < Test::Unit::TestCase Capybara::Driver::Akephalos.new(app, :validate_scripts => false) end session = Capybara::Session.new(:akephalos) - session.visit File.join(CONFIG[:services]["opentox-toxcreate"], "predict")#CONFIG[:services]["opentox-toxcreate"] + session.visit File.join(CONFIG[:services]["opentox-toxcreate"], "predict") #session.click_on "Predict" session.fill_in('identifier', :with => "NNc1ccccc1") session.check "hamster_carcinogenicity" @@ -79,41 +80,43 @@ class ToxCreateTest < Test::Unit::TestCase assert session.has_content? "false" assert session.has_content? "0.294" assert session.has_content? "0.875" + assert session.has_content? "next" Capybara.reset_sessions! end def test_04_inspect_policies - visit File.join(CONFIG[:services]["opentox-toxcreate"], "models")#visit CONFIG[:services]["opentox-toxcreate"] + #Capybara.current_driver = :selenium + visit File.join(CONFIG[:services]["opentox-toxcreate"], "models") #click_on "Inspect" assert first('h2').has_content? 'hamster_carcinogenicity' 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 + within(:xpath, '//form[contains(@id, "_policy_group_member")]') do + find(:xpath, './/input[3]').click click_on "update" end + sleep 5 end def test_05_inspect_policies - #visit CONFIG[:services]["opentox-toxcreate"] + visit File.join(CONFIG[:services]["opentox-toxcreate"], "models") #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 + assert first('h2').has_content? 'hamster_carcinogenicity' + click_on("protect data") + within(:xpath, '//form[contains(@id, "_member")]') do find(:xpath, './/input[4]').click - click_on "update" - end + click_on "add" + end + sleep 5 end def test_06_inspect_policies - #visit CONFIG[:services]["opentox-toxcreate"] + visit File.join(CONFIG[:services]["opentox-toxcreate"], "models") #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 + assert first('h2').has_content? 'hamster_carcinogenicity' + click_on("protect data") + within(:xpath, '//form[contains(@id, "_development")]') do find(:xpath, './/input[4]').click click_on "add" end @@ -121,53 +124,72 @@ class ToxCreateTest < Test::Unit::TestCase end def test_07_inspect_policies - #visit CONFIG[:services]["opentox-toxcreate"] + visit File.join(CONFIG[:services]["opentox-toxcreate"], "models") #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 + assert first('h2').has_content? 'hamster_carcinogenicity' + click_on("protect data") + within(:xpath, '//form[contains(@id, "_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" + page.evaluate_script('window.confirm = function() { return true; }') + sleep 5 end =begin 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_10_kazius - Capybara.current_driver = :akephalos + #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 - +=end def test_11_parallel_models - #login(@browser, @user, @password) - 10.times do - visit CONFIG[:services]["opentox-toxcreate"] + 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_12_toxcreate_sdf # works only with akephalos Capybara.current_driver = :akephalos -- cgit v1.2.3