From 16fdf49682898277566978a11df5e4d1ca7011c3 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 22 Mar 2011 12:19:12 +0100 Subject: - --- toxcreate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toxcreate.rb b/toxcreate.rb index 368101b..c0522c3 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -18,8 +18,8 @@ class ToxCreateTest < Test::Unit::TestCase def teardown @browser.close end - =end + def test_toxcreate @browser.goto CONFIG[:services]["opentox-toxcreate"] @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/hamster_carcinogenicity.csv") -- cgit v1.2.3 From 4a3babce16c811ba3044c460533707b469b3c263 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 5 Apr 2011 19:05:59 +0200 Subject: lazar model from ambit datasets --- algorithm.rb | 3 +- feature.rb | 2 +- fminer.rb | 23 ++++++------ lazar.rb | 117 ++++++++++++++++++++++++++++++++++++++++++----------------- 4 files changed, 97 insertions(+), 48 deletions(-) diff --git a/algorithm.rb b/algorithm.rb index 650a6df..772979b 100644 --- a/algorithm.rb +++ b/algorithm.rb @@ -20,8 +20,7 @@ class AlgorithmTest < Test::Unit::TestCase def test_metadata @algorithms.each do |algorithm| - #puts algorithm - validate_owl(algorithm, @@subjectid) + validate_owl(algorithm, @@subjectid) unless CONFIG[:services]["opentox-algorithm"].match(/localhost/) end end diff --git a/feature.rb b/feature.rb index 7ed600c..523688f 100644 --- a/feature.rb +++ b/feature.rb @@ -25,7 +25,7 @@ class FeatureTest < Test::Unit::TestCase def test_owl #@features.each do |uri| - validate_owl @features.first, @@subjectid + validate_owl @features.first, @@subjectid unless CONFIG[:services]["opentox-dataset"].match(/localhost/) # Ambit does not validate #end end diff --git a/fminer.rb b/fminer.rb index 362bde9..3e6dd0d 100644 --- a/fminer.rb +++ b/fminer.rb @@ -12,27 +12,29 @@ class FminerTest < Test::Unit::TestCase dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 41, d.features.size + #puts dataset_uri + assert_equal 52, d.features.size #validate_owl d.delete(@@subjectid) end - def test_last - feature = @@classification_training_dataset.features.keys.first - dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s + def test_regression_bbrc + feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" + dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 35, d.features.size - #validate_owl + assert_equal 1354, d.features.size d.delete(@@subjectid) end - def test_regression_bbrc - feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" - dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s +=begin + def test_last + feature = @@classification_training_dataset.features.keys.first + dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 225, d.features.size + assert_equal 35, d.features.size + #validate_owl d.delete(@@subjectid) end @@ -44,7 +46,6 @@ class FminerTest < Test::Unit::TestCase assert_equal 16, d.features.size d.delete(@@subjectid) end -=begin =end end diff --git a/lazar.rb b/lazar.rb index 1eb7645..512a614 100644 --- a/lazar.rb +++ b/lazar.rb @@ -8,62 +8,111 @@ class Float end end -class LazarRegressionTest < Test::Unit::TestCase +class LazarTest < Test::Unit::TestCase + + def setup + @predictions = [] + @models = [] + end + + def teardown + @predictions.each {|p| p.delete(@@subjectid)} + @models.each {|m| m.delete(@@subjectid)} + end =begin =end def test_create_regression_model model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid}).to_s - @lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid - assert_equal 225, @lazar.features.size + lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid + @models << lazar + assert_equal 1354, lazar.features.size compound = OpenTox::Compound.from_smiles("c1ccccc1NN") - prediction_uri = @lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid).to_s - @prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) - assert_equal @prediction.value(compound).round_to(4), 0.1618.round_to(4) - assert_equal @prediction.confidence(compound).round_to(4), 0.6114.round_to(4) - assert_equal @prediction.neighbors(compound).size, 81 - @prediction.delete(@@subjectid) - @lazar.delete(@@subjectid) + prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid).to_s + prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) + @predictions << prediction + assert_equal prediction.value(compound).round_to(4), 0.17.round_to(4) + assert_equal prediction.confidence(compound).round_to(4), 0.5697.round_to(4) + assert_equal prediction.neighbors(compound).size, 77 end -end -class LazarClassificationTest < Test::Unit::TestCase + def test_classification_model # create model model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@classification_training_dataset.uri, :subjectid => @@subjectid}).to_s - @lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid - assert_equal @lazar.features.size, 41 + lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid + @models << lazar + assert_equal lazar.features.size, 52 # single prediction compound = OpenTox::Compound.from_smiles("c1ccccc1NN") - prediction_uri = @lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) - @prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) - assert_equal @prediction.value(compound), false - assert_equal @prediction.confidence(compound).round_to(4), 0.3005.round_to(4) - assert_equal @prediction.neighbors(compound).size, 15 - @prediction.delete(@@subjectid) + prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) + prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) + @predictions << prediction + assert_equal prediction.value(compound), false + assert_equal prediction.confidence(compound).round_to(4), 0.3067.round_to(4) + assert_equal prediction.neighbors(compound).size, 14 # dataset activity compound = OpenTox::Compound.from_smiles("CNN") - prediction_uri = @lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) - @prediction = OpenTox::LazarPrediction.find prediction_uri, @@subjectid - assert !@prediction.measured_activities(compound).empty? - assert_equal @prediction.measured_activities(compound).first, true - assert @prediction.value(compound).nil? - @prediction.delete(@@subjectid) + prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) + prediction = OpenTox::LazarPrediction.find prediction_uri, @@subjectid + @predictions << prediction + assert !prediction.measured_activities(compound).empty? + assert_equal prediction.measured_activities(compound).first, true + assert prediction.value(compound).nil? # dataset prediction test_dataset = OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid) - @prediction = OpenTox::LazarPrediction.find @lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid), @@subjectid - assert_equal @prediction.compounds.size, 4 - compound = OpenTox::Compound.new "http://ot-dev.in-silico.ch/compound/InChI=1S/C15H13NO/c1-10(17)16-13-6-7-15-12(9-13)8-11-4-2-3-5-14(11)15/h2-7,9H,8H2,1H3,(H,16,17)" - assert_equal @prediction.value(compound), nil - assert_equal @prediction.measured_activities(compound).first, true - @prediction.delete(@@subjectid) - @lazar.delete(@@subjectid) + prediction = OpenTox::LazarPrediction.find lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid), @@subjectid + @predictions << prediction + assert_equal prediction.compounds.size, 4 + compound = OpenTox::Compound.from_smiles "CC(=Nc1ccc2c(c1)Cc1ccccc21)O" + assert_equal prediction.value(compound), nil + assert_equal prediction.measured_activities(compound).first, true end + def test_ambit_classification_model + + # create model + dataset_uri = "http://apps.ideaconsult.net:8080/ambit2/dataset/9" + feature_uri ="http://apps.ideaconsult.net:8080/ambit2/feature/21573" + #model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => dataset_uri, :prediction_feature => feature_uri}).to_s + #lazar = OpenTox::Model::Lazar.find model_uri + model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => dataset_uri, :prediction_feature => feature_uri, :subjectid => @@subjectid}).to_s + lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid + assert_equal lazar.features.size, 6609 + #puts "Model: #{lazar.uri}" + #puts lazar.features.size + + # single prediction + compound = OpenTox::Compound.from_smiles("c1ccccc1NN") + #prediction_uri = lazar.run(:compound_uri => compound.uri) + #prediction = OpenTox::LazarPrediction.find(prediction_uri) + prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) + prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) + #puts "Prediction: #{prediction.uri}" + #puts prediction.value(compound) + assert_equal prediction.value(compound), true + #puts @prediction.confidence(compound).round_to(4) + #assert_equal @prediction.confidence(compound).round_to(4), 0.3005.round_to(4) + #assert_equal @prediction.neighbors(compound).size, 15 + #@prediction.delete(@@subjectid) + + # dataset activity + #compound = OpenTox::Compound.from_smiles("CNN") + #prediction_uri = @lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) + #@prediction = OpenTox::LazarPrediction.find prediction_uri, @@subjectid + #assert !@prediction.measured_activities(compound).empty? + #assert_equal @prediction.measured_activities(compound).first, true + #assert @prediction.value(compound).nil? + #@prediction.delete(@@subjectid) + + # dataset prediction + #@lazar.delete(@@subjectid) + end + +end =begin =end -end -- cgit v1.2.3 From 27834664626b3718502652309f461f2d3d8b6be8 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 11 Apr 2011 11:46:35 +0200 Subject: Updated expected feature count --- fminer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fminer.rb b/fminer.rb index 3e6dd0d..85b58fb 100644 --- a/fminer.rb +++ b/fminer.rb @@ -23,7 +23,7 @@ class FminerTest < Test::Unit::TestCase dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 1354, d.features.size + assert_equal 1356, d.features.size d.delete(@@subjectid) end -- cgit v1.2.3 From a6d7aad971c3344c0cc092787e0e740e489ee8b4 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 11 Apr 2011 14:23:04 +0200 Subject: Fixed Fminer tests --- fminer.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fminer.rb b/fminer.rb index 85b58fb..781fb91 100644 --- a/fminer.rb +++ b/fminer.rb @@ -5,16 +5,12 @@ require 'validate-owl.rb' class FminerTest < Test::Unit::TestCase -=begin -=end def test_bbrc feature = @@classification_training_dataset.features.keys.first dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - #puts dataset_uri assert_equal 52, d.features.size - #validate_owl d.delete(@@subjectid) end @@ -27,14 +23,12 @@ class FminerTest < Test::Unit::TestCase d.delete(@@subjectid) end -=begin def test_last feature = @@classification_training_dataset.features.keys.first dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 35, d.features.size - #validate_owl + assert_equal 23, d.features.size d.delete(@@subjectid) end @@ -43,9 +37,8 @@ class FminerTest < Test::Unit::TestCase dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 16, d.features.size + assert_equal 4, d.features.size d.delete(@@subjectid) end -=end end -- cgit v1.2.3 From 72eddb952b12169283a4a806cf90f50573b7e145 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 11 Apr 2011 16:27:40 +0200 Subject: add missing subjectid --- dataset.rb | 2 +- feature.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dataset.rb b/dataset.rb index 1e4134b..17d15f2 100644 --- a/dataset.rb +++ b/dataset.rb @@ -47,7 +47,7 @@ class DatasetTest < Test::Unit::TestCase end def test_all - datasets = OpenTox::Dataset.all + datasets = OpenTox::Dataset.all(CONFIG[:services]["opentox-dataset"], @@subjectid) assert_kind_of Array, datasets end diff --git a/feature.rb b/feature.rb index 523688f..6ecf2cf 100644 --- a/feature.rb +++ b/feature.rb @@ -17,7 +17,7 @@ class FeatureTest < Test::Unit::TestCase @features.each do |uri| f = OpenTox::Feature.new(uri) - f.load_metadata + f.load_metadata(@@subjectid) assert_not_nil f.metadata[DC.title] assert_not_nil f.metadata[OT.hasSource] end -- cgit v1.2.3 From f9b5ac3d7bd7c12bdabfe687398ebf8f6c1551a0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 14 Apr 2011 14:35:15 +0200 Subject: nr of features in lazar model fixed --- lazar.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lazar.rb b/lazar.rb index 512a614..e2dd12a 100644 --- a/lazar.rb +++ b/lazar.rb @@ -26,7 +26,7 @@ class LazarTest < Test::Unit::TestCase model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid}).to_s lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid @models << lazar - assert_equal 1354, lazar.features.size + assert_equal 1356, lazar.features.size compound = OpenTox::Compound.from_smiles("c1ccccc1NN") prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid).to_s prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) @@ -112,7 +112,7 @@ class LazarTest < Test::Unit::TestCase # dataset prediction #@lazar.delete(@@subjectid) end - -end =begin =end + +end -- cgit v1.2.3 From 517c1e43cdf63068d6bb1b5a948eb419465cf4d4 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 20 Apr 2011 11:31:02 +0200 Subject: login tests --- toxcreate.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/toxcreate.rb b/toxcreate.rb index c0522c3..c11881e 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -11,10 +11,29 @@ class ToxCreateTest < Test::Unit::TestCase @password = "test_ch" end -=begin def test_login + @browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login") + @browser.button(:value, "Login").click + puts "Login without credentials" + assert @browser.text.include? "Please enter username and password." + @browser.text_field(:id, "username").set(@user) + @browser.text_field(:id, "password").set(@password + "nonsense") + @browser.button(:value, "Login").click + puts "Login with wrong password" + assert @browser.text.include? "Login failed. Please try again." + @browser.text_field(:id, "username").set(@user) + @browser.text_field(:id, "password").set(@password) + @browser.button(:value, "Login").click + puts "Login as user #{@user}" + assert @browser.text.include? "Welcome #{@user}!" + @browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login") + @browser.button(:value, "Login as guest").click + puts "Login as user guest" + assert @browser.text.include? "Welcome guest!" + @browser.close end +=begin def teardown @browser.close end -- cgit v1.2.3 From 76c6355f61251c0fc11f0ce0fbb358b4c6ce433c Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 3 May 2011 17:50:33 +0200 Subject: load setup in Rakefile for parser test --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 45affdc..42f8b15 100644 --- a/Rakefile +++ b/Rakefile @@ -31,7 +31,7 @@ task :teardown do end #[:all, :feature, :dataset, :fminer, :lazar, :authorization, :validation].each do |t| -[:all, :feature, :dataset, :fminer, :lazar, :authorization].each do |t| +[:all, :feature, :dataset, :fminer, :lazar, :authorization, :parser].each do |t| task :teardown => t task t => :setup end -- cgit v1.2.3 From 73bfe27cf9d62593c426d8742df18e3b47388ff1 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 3 May 2011 17:51:57 +0200 Subject: toxcreate tests with login function for A&A --- toxcreate.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/toxcreate.rb b/toxcreate.rb index c11881e..5a995e2 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -10,7 +10,8 @@ class ToxCreateTest < Test::Unit::TestCase @user = "test_ch" @password = "test_ch" end - + +=begin def test_login @browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login") @browser.button(:value, "Login").click @@ -33,13 +34,14 @@ class ToxCreateTest < Test::Unit::TestCase @browser.close end -=begin + def teardown @browser.close end -=end + def test_toxcreate + login(@browser, @user, @password) @browser.goto CONFIG[:services]["opentox-toxcreate"] @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/hamster_carcinogenicity.csv") @browser.button(:value, "Create model").click @@ -47,9 +49,10 @@ class ToxCreateTest < Test::Unit::TestCase # check results (links, reports, results) puts @browser.url end - +=end =begin def test_multi_cell_call + login(@browser, @user, @password) @browser.goto CONFIG[:services]["opentox-toxcreate"] @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/multi_cell_call.csv") @browser.button(:value, "Create model").click @@ -59,6 +62,7 @@ class ToxCreateTest < Test::Unit::TestCase end def test_kazius + login(@browser, @user, @password) @browser.goto CONFIG[:services]["opentox-toxcreate"] @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/kazius.csv") @browser.button(:value, "Create model").click @@ -68,6 +72,7 @@ class ToxCreateTest < Test::Unit::TestCase end def test_parallel_models + login(@browser, @user, @password) 10.times do @browser.goto CONFIG[:services]["opentox-toxcreate"] @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/hamster_carcinogenicity.csv") @@ -77,3 +82,10 @@ class ToxCreateTest < Test::Unit::TestCase end =end end + +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 \ No newline at end of file -- cgit v1.2.3 From adc6cba3b1431c59ee2fa9dee0b4b7b2b8f5b29f Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 4 May 2011 15:25:35 +0200 Subject: Fixed BBRC regression and disabled LAST regression --- fminer.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fminer.rb b/fminer.rb index 781fb91..1f99f77 100644 --- a/fminer.rb +++ b/fminer.rb @@ -16,10 +16,10 @@ class FminerTest < Test::Unit::TestCase def test_regression_bbrc feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" - dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s + dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid, :feature_type=>"paths"}).to_s d =OpenTox::Dataset.new dataset_uri, @@subjectid d.load_features(@@subjectid) - assert_equal 1356, d.features.size + assert_equal 185, d.features.size d.delete(@@subjectid) end @@ -32,13 +32,14 @@ class FminerTest < Test::Unit::TestCase d.delete(@@subjectid) end - def test_regression_last - feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" - dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s - d =OpenTox::Dataset.new dataset_uri, @@subjectid - d.load_features(@@subjectid) - assert_equal 4, d.features.size - d.delete(@@subjectid) - end +# Deactivated by AM because of efficiency problems (does not return) +# def test_regression_last +# feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" +# dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s +# d =OpenTox::Dataset.new dataset_uri, @@subjectid +# d.load_features(@@subjectid) +# assert_equal 4, d.features.size +# d.delete(@@subjectid) +# end end -- cgit v1.2.3 From 6f89d7448d861f665d6c506e27db31984bd62808 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Mon, 9 May 2011 16:11:28 +0200 Subject: moved validation-unit-tests to test repository --- Rakefile | 2 +- data/EPAFHM.mini.csv | 21 +++ data/hamster_carcinogenicity.mini.csv | 11 ++ validation.rb | 335 ++++++++++++++++++++++++++++++---- validation_util.rb | 46 +++++ 5 files changed, 379 insertions(+), 36 deletions(-) create mode 100644 data/EPAFHM.mini.csv create mode 100644 data/hamster_carcinogenicity.mini.csv create mode 100755 validation_util.rb diff --git a/Rakefile b/Rakefile index 42f8b15..49b72f8 100644 --- a/Rakefile +++ b/Rakefile @@ -31,7 +31,7 @@ task :teardown do end #[:all, :feature, :dataset, :fminer, :lazar, :authorization, :validation].each do |t| -[:all, :feature, :dataset, :fminer, :lazar, :authorization, :parser].each do |t| +[:all, :feature, :dataset, :fminer, :lazar, :authorization, :parser, :validation ].each do |t| task :teardown => t task t => :setup end diff --git a/data/EPAFHM.mini.csv b/data/EPAFHM.mini.csv new file mode 100644 index 0000000..c86cd33 --- /dev/null +++ b/data/EPAFHM.mini.csv @@ -0,0 +1,21 @@ +"STRUCTURE_SMILES","LC50_mmol" +"C1=CC(C=O)=CC(OC)=C1OCCCCCC",1.13E-02 +"C1(OC)=C([N+]([O-])=O)C(C=O)=CC(Br)=C1O",2.66E-01 +"CCCCCCCCOC(=O)C1=CC=CC(C(=O)OCCCCCCCC)=C1", +"C1=CC(Cl)=CC=C1OC2=C([N+](=O)[O-])C=CC=C2",7.69E-03 +"CC1=C(NC=O)C=CC=C1Cl",2.75E-01 +"CCCCOC(=O)C1=CC=CC(C(=O)OCCCC)=C1",3.23E-03 +"C(C1=CC=CC=C1)(C2=CC=CC=C2)(O)C#C",5.33E-02 +"CCCSCCSCCC",4.22E-02 +"CCCCCCCCOC(=O)C1=CC=C(C(=O)OCCCCCCCC)C=C1", +"OCCCCOC(=O)C1=CC=CC=C1C(=O)OCCCCOC(=O)C2=CC=CC=C2C(=O)OCCCCO", +"CCCSCCCCSCCC",1.45E-02 +"C1([N+](=O)[O-])=CC=C(C)C=C1OP(=O)(OC2=C([N+](=O)[O-])C=CC(C)=C2)OC3=C([N+]([O-])=O)C=CC(C)=C3", +"C1=C([N+]([O-])=O)C=CC=C1P(=O)(C2=CC([N+](=O)[O-])=CC=C2)C3=CC([N+](=O)[O-])=CC=C3", +"ClCCOC(=O)NC1CCCCC1",1.70E-01 +"O=C1C(C2=CC=CC=C2)(C(=O)NC(=O)N1)CC",2.08E+00 +"OC1=C(C=C(C=C1)[N+](=O)[O-])[N+](=O)[O-]",5.92E-02 +"NC(=O)OCC",5.88E+01 +"[O-]C(C1=CC=CC=C1O)=O.[Na+]",1.25E+01 +"C1=CC=CC=C1C(=O)N",5.46E+00 +"CC[N+](CC)(CC)CC1(=CC=CC=C1).[Cl-]",7.07E-01 diff --git a/data/hamster_carcinogenicity.mini.csv b/data/hamster_carcinogenicity.mini.csv new file mode 100644 index 0000000..4267235 --- /dev/null +++ b/data/hamster_carcinogenicity.mini.csv @@ -0,0 +1,11 @@ +SMILES, Hamster Carcinogenicity +CC=O,1 +C12C3=C(C=CC=C3)CC1=CC(=CC=2)NC(C)=O,1 +O=C(N)\C(C2=CC=CO2)=C/C1=CC=C([N+]([O-])=O)O1,1 +C1(N=CNN=1)N,0 +Br(=O)(=O)[O-].[K+],1 +[Cl-].[Cd+2].[Cl-],0 +O=S(=O)([O-])[O-].[Cd+2],0 +ClC1=CC(=NC(=N1)SCC(=O)O)NC2=CC=CC(=C2C)C,0 +ClCOC,1 +C=C(Cl)C=C,0 diff --git a/validation.rb b/validation.rb index beb1c02..0946cf9 100644 --- a/validation.rb +++ b/validation.rb @@ -1,45 +1,310 @@ -require 'rubygems' -require 'opentox-ruby' +ENV['RACK_ENV'] = 'production' + require 'test/unit' +require 'validation_util.rb' + +#TEST_USER = "guest" +#TEST_PW = "guest" + +#LOGGER = OTLogger.new(STDOUT) +#LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S " +#LOGGER.formatter = Logger::Formatter.new -class Float - def round_to(x) - (self * 10**x).round.to_f / 10**x +module Sinatra + set :raise_errors, false + set :show_exceptions, false +end + +class Exception + def message + errorCause ? errorCause.to_yaml : to_s end end class ValidationTest < Test::Unit::TestCase + + def global_setup + puts "login and upload datasets" + if AA_SERVER + @@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) + raise "could not log in" unless @@subjectid + puts "logged in: "+@@subjectid.to_s + else + puts "AA disabled" + @@subjectid = nil + end + + @@data = [] + files = { File.new("data/hamster_carcinogenicity.mini.csv") => :crossvalidation, + File.new("data/EPAFHM.mini.csv") => :crossvalidation, + File.new("data/hamster_carcinogenicity.csv") => :validation, + File.new("data/EPAFHM.csv") => :validation, +# File.new("data/StJudes-HepG2-testset_Class.csv") => :crossvalidation + } + files.each do |file,type| + @@data << { :type => type, + :data => ValidationTestUtil.upload_dataset(file, @@subjectid), + :feat => ValidationTestUtil.prediction_feature_for_file(file), + :info => file.path, :delete => true} + end +# @@data << { :type => :crossvalidation, +# :data => "http://apps.ideaconsult.net:8080/ambit2/dataset/9?max=50", +# :feat => "http://apps.ideaconsult.net:8080/ambit2/feature/21573", +# :info => "http://apps.ideaconsult.net:8080/ambit2/dataset/9?max=50" } +# @@data << { :type => :validation, +# :data => "http://apps.ideaconsult.net:8080/ambit2/dataset/272?max=50", +# :feat => "http://apps.ideaconsult.net:8080/ambit2/feature/26221", +# :info => "http://apps.ideaconsult.net:8080/ambit2/dataset/272?max=50" } + end + + def global_teardown + puts "delete and logout" + @@data.each{|data| OpenTox::Dataset.find(data[:data],@@subjectid).delete(@@subjectid) if data[:delete]} + @@vs.each{|v| v.delete(@@subjectid)} if defined?@@vs + @@cvs.each{|cv| cv.delete(@@subjectid)} if defined?@@cvs + @@reports.each{|report| report.delete(@@subjectid)} if defined?@@reports + @@qmrfReports.each{|qmrfReport| qmrfReport.delete(@@subjectid)} if defined?@@qmrfReports + OpenTox::Authorization.logout(@@subjectid) if AA_SERVER + end + + def test_validation_list + puts "test_validation_list" + list = OpenTox::Validation.list + assert list.is_a?(Array) + list.each do |l| + assert l.uri? + end + end + + def test_training_test_split + + @@vs = [] + @@data.each do |data| + if data[:type]==:validation + puts "test_training_test_split "+data[:info].to_s + p = { + :dataset_uri => data[:data], + :algorithm_uri => File.join(CONFIG[:services]["opentox-algorithm"],"lazar"), + :algorithm_params => "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer/bbrc"), + :prediction_feature => data[:feat], + :split_ratio => 0.95, + :random_seed => 2} + t = OpenTox::SubTask.new(nil,0,1) + def t.progress(pct) + if !defined?@last_msg or @last_msg+3 model} ) + assert v_list.size==1 and v_list.include?(v.uri) + @@vs << v + end + end + end + + def test_validation_report + #@@cv = OpenTox::Crossvalidation.find("http://local-ot/validation/crossvalidation/48", @@subjectid) + + @@reports = [] unless defined?@@reports + @@vs.each do |v| + puts "test_validation_report" + assert defined?v,"no validation defined" + assert_kind_of OpenTox::Validation,v + if @@subjectid + assert_rest_call_error OpenTox::NotAuthorizedError do + OpenTox::CrossvalidationReport.create(v.uri) + end + end + report = OpenTox::ValidationReport.find_for_validation(v.uri,@@subjectid) + assert report==nil,"report already exists for validation\nreport: "+(report ? report.uri.to_s : "")+"\nvalidation: "+v.uri.to_s + report = OpenTox::ValidationReport.create(v.uri,@@subjectid) + assert report.uri.uri? + if @@subjectid + assert_rest_call_error OpenTox::NotAuthorizedError do + OpenTox::CrossvalidationReport.find(report.uri) + end + end + report = OpenTox::ValidationReport.find(report.uri,@@subjectid) + assert report.uri.uri? + report2 = OpenTox::ValidationReport.find_for_validation(v.uri,@@subjectid) + assert_equal report.uri,report2.uri + report3_uri = v.find_or_create_report(@@subjectid) + assert_equal report.uri,report3_uri + @@reports << report2 + end + end + + def test_crossvalidation_list + puts "test_crossvalidation_list" + list = OpenTox::Crossvalidation.list + assert list.is_a?(Array) + list.each do |l| + assert l.uri? + end + end -=begin -=end def test_crossvalidation -=begin -=end - puts "creating model ..." - model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@classification_training_dataset.uri, :subjectid => @@subjectid}).to_s - lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid - puts @@classification_training_dataset.features.to_yaml - params = { - :algorithm_uri => File.join(CONFIG[:services]["opentox-algorithm"],"lazar"), - :dataset_uri => lazar.parameter("dataset_uri"), - #:dataset_uri => @@classification_training_dataset.uri, - :subjectid => @@subjectid, - #:prediction_feature => @@classification_training_dataset.features.keys.first, - #:algorithm_params => "feature_generation_uri=#{File.join(CONFIG[:services]["opentox-algorithm"],"bbrc")}" - :prediction_feature => lazar.parameter("prediction_feature"), - :algorithm_params => "feature_generation_uri=#{lazar.parameter("feature_generation_uri")}" - } - puts params.to_yaml - cv = OpenTox::Validation.create_crossvalidation(params) - puts cv.uri - #@@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) - cv = OpenTox::Validation.new "http://opentox.informatik.uni-freiburg.de/validation/crossvalidation/6" - puts cv.uri - #puts cv.create_report(@@subjectid) - #puts cv.create_qmrf_report(@@subjectid) - #v = YAML.load OpenTox::RestClientWrapper.get(cv.uri,{:accept => "application/x-yaml", :subjectid => @@subjectid}).to_s - v = YAML.load OpenTox::RestClientWrapper.get(File.join(cv.uri, 'statistics'),{:accept => "application/x-yaml", :subjectid => @@subjectid}).to_s - puts v.to_yaml - #puts cv.summary("classification",@@subjectid) + + #assert_rest_call_error OpenTox::NotFoundError do + # OpenTox::Crossvalidation.find(File.join(CONFIG[:services]["opentox-validation"],"crossvalidation/noexistingid")) + #end + @@cvs = [] + @@data.each do |data| + if data[:type]==:crossvalidation + puts "test_crossvalidation "+data[:info].to_s + p = { + :dataset_uri => data[:data], + :algorithm_uri => File.join(CONFIG[:services]["opentox-algorithm"],"lazar"), + :algorithm_params => "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer/bbrc"), + :prediction_feature => data[:feat], + :num_folds => 2 } + t = OpenTox::SubTask.new(nil,0,1) + def t.progress(pct) + if !defined?@last_msg or @last_msg+3 algorithm} ) + assert cv_list.include?(cv.uri) + cv_list.each do |cv_uri| + alg = OpenTox::Crossvalidation.find(cv_uri).metadata[OT.algorithm] + assert alg==algorithm,"wrong algorithm for filtered crossvalidation, should be: '"+algorithm.to_s+"', is: '"+alg.to_s+"'" + end + + @@cvs << cv + end + end + end + + def test_crossvalidation_report + #@@cv = OpenTox::Crossvalidation.find("http://local-ot/validation/crossvalidation/48", @@subjectid) + + @@reports = [] unless defined?@@reports + @@cvs.each do |cv| + puts "test_crossvalidation_report" + assert defined?cv,"no crossvalidation defined" + assert_kind_of OpenTox::Crossvalidation,cv + #assert_rest_call_error OpenTox::NotFoundError do + # OpenTox::CrossvalidationReport.find_for_crossvalidation(cv.uri) + #end + if @@subjectid + assert_rest_call_error OpenTox::NotAuthorizedError do + OpenTox::CrossvalidationReport.create(cv.uri) + end + end + assert OpenTox::ValidationReport.find_for_validation(cv.uri,@@subjectid)==nil + report = OpenTox::CrossvalidationReport.create(cv.uri,@@subjectid) + assert report.uri.uri? + if @@subjectid + assert_rest_call_error OpenTox::NotAuthorizedError do + OpenTox::CrossvalidationReport.find(report.uri) + end + end + report = OpenTox::CrossvalidationReport.find(report.uri,@@subjectid) + assert report.uri.uri? + report2 = OpenTox::CrossvalidationReport.find_for_crossvalidation(cv.uri,@@subjectid) + assert_equal report.uri,report2.uri + report3_uri = cv.find_or_create_report(@@subjectid) + assert_equal report.uri,report3_uri + @@reports << report2 + end + end + + def test_qmrf_report + #@@cv = OpenTox::Crossvalidation.find("http://local-ot/validation/crossvalidation/13", @@subjectid) + + @@qmrfReports = [] + @@cvs.each do |cv| + puts "test_qmrf_report" + assert defined?cv,"no crossvalidation defined" + validations = cv.metadata[OT.validation] + assert_kind_of Array,validations + assert validations.size==cv.metadata[OT.numFolds].to_i,validations.size.to_s+"!="+cv.metadata[OT.numFolds].to_s + val = OpenTox::Validation.find(validations[0], @@subjectid) + model_uri = val.metadata[OT.model] + + model = OpenTox::Model::Generic.find(model_uri, @@subjectid) + assert model!=nil + + #assert_rest_call_error OpenTox::NotFoundError do + # OpenTox::QMRFReport.find_for_model(model_uri, @@subjectid) + #end + + @@qmrfReports << OpenTox::QMRFReport.create(model_uri, @@subjectid) + end + end + + ################### utils and overrides ########################## + + def app + Sinatra::Application end + + # checks RestCallError type + def assert_rest_call_error( ex ) + if ex==OpenTox::NotAuthorizedError and @@subjectid==nil + puts "AA disabled: skipping test for not authorized" + return + end + begin + yield + rescue OpenTox::RestCallError => e + report = e.errorCause + while report.errorCause + report = report.errorCause + end + assert_equal report.errorType,ex.to_s + end + end + + # hack to have a global_setup and global_teardown + def teardown + if((@@expected_test_count-=1) == 0) + global_teardown + end + end + def setup + unless defined?@@expected_test_count + @@expected_test_count = (self.class.instance_methods.reject{|method| method[0..3] != 'test'}).length + global_setup + end + end + end + + diff --git a/validation_util.rb b/validation_util.rb new file mode 100755 index 0000000..a5206b3 --- /dev/null +++ b/validation_util.rb @@ -0,0 +1,46 @@ + +require 'test/unit' + + class ValidationTestUtil + + @@dataset_uris = {} + @@prediction_features = {} + + def self.upload_dataset(file, subjectid=nil, dataset_service=CONFIG[:services]["opentox-dataset"]) #, file_type="application/x-yaml") + raise "File not found: "+file.path.to_s unless File.exist?(file.path) + if @@dataset_uris[file.path.to_s]==nil + LOGGER.debug "uploading file: "+file.path.to_s + if (file.path =~ /yaml$/) + data = File.read(file.path) + #data_uri = OpenTox::RestClientWrapper.post(dataset_service,{:content_type => file_type},data).to_s.chomp + #@@dataset_uris[file.path.to_s] = data_uri + #LOGGER.debug "uploaded dataset: "+data_uri + d = OpenTox::Dataset.create(CONFIG[:services]["opentox-dataset"], subjectid) + d.load_yaml(data) + d.save( subjectid ) + @@dataset_uris[file.path.to_s] = d.uri + elsif (file.path =~ /csv$/) + d = OpenTox::Dataset.create_from_csv_file(file.path, subjectid) + raise "num features not 1 (="+d.features.keys.size.to_s+"), what to predict??" if d.features.keys.size != 1 + @@prediction_features[file.path.to_s] = d.features.keys[0] + @@dataset_uris[file.path.to_s] = d.uri + elsif (file.path =~ /rdf$/) + d = OpenTox::Dataset.create(CONFIG[:services]["opentox-dataset"], subjectid) + d.load_rdfxml_file(file, subjectid) + d.save(subjectid) + @@dataset_uris[file.path.to_s] = d.uri + else + raise "unknown file type: "+file.path.to_s + end + LOGGER.debug "uploaded dataset: "+d.uri + else + LOGGER.debug "file already uploaded: "+@@dataset_uris[file.path.to_s] + end + return @@dataset_uris[file.path.to_s] + end + + def self.prediction_feature_for_file(file) + @@prediction_features[file.path.to_s] + end + + end -- cgit v1.2.3 From d2ca1d714686a23e9e27c9f2845de6cc03f12b73 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Tue, 10 May 2011 12:38:23 +0200 Subject: add date tests to validation unit tests --- validation.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/validation.rb b/validation.rb index 0946cf9..ad9984e 100644 --- a/validation.rb +++ b/validation.rb @@ -105,8 +105,8 @@ class ValidationTest < Test::Unit::TestCase end end v = OpenTox::Validation.find(v.uri, @@subjectid) + assert_valid_date v assert v.uri.uri? - model = v.metadata[OT.model] assert model.uri? v_list = OpenTox::Validation.list( {:model => model} ) @@ -139,6 +139,7 @@ class ValidationTest < Test::Unit::TestCase end end report = OpenTox::ValidationReport.find(report.uri,@@subjectid) + assert_valid_date report assert report.uri.uri? report2 = OpenTox::ValidationReport.find_for_validation(v.uri,@@subjectid) assert_equal report.uri,report2.uri @@ -188,6 +189,7 @@ class ValidationTest < Test::Unit::TestCase end end cv = OpenTox::Crossvalidation.find(cv.uri, @@subjectid) + assert_valid_date cv assert cv.uri.uri? if @@subjectid assert_rest_call_error OpenTox::NotAuthorizedError do @@ -236,6 +238,7 @@ class ValidationTest < Test::Unit::TestCase end end report = OpenTox::CrossvalidationReport.find(report.uri,@@subjectid) + assert_valid_date report assert report.uri.uri? report2 = OpenTox::CrossvalidationReport.find_for_crossvalidation(cv.uri,@@subjectid) assert_equal report.uri,report2.uri @@ -292,6 +295,17 @@ class ValidationTest < Test::Unit::TestCase end end + # checks if opento_object has date defined in metadata, and time is less than max_time seconds ago + def assert_valid_date( opentox_object, max_time=600 ) + + raise "no opentox object" unless opentox_object.class.to_s.split("::").first=="OpenTox" + assert opentox_object.metadata.is_a?(Hash) + assert opentox_object.metadata[DC.date].to_s.length>0,"date not set for "+opentox_object.uri.to_s+", is metadata loaded? (use find)" + time = Time.parse(opentox_object.metadata[DC.date]) + assert timeTime.new-(10*60),opentox_object.uri.to_s+" took longer than 10 minutes "+time.to_s + end + # hack to have a global_setup and global_teardown def teardown if((@@expected_test_count-=1) == 0) -- cgit v1.2.3 From 58c449915b607783738ae86f5b5d6ea2b668a0ea Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 12 May 2011 19:19:46 +0200 Subject: test fixed for linear fragments in regression bbrc --- feature.rb | 2 +- lazar.rb | 9 ++++----- validate-owl.rb | 2 -- validation.rb | 2 ++ 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/feature.rb b/feature.rb index 6ecf2cf..c06f9f5 100644 --- a/feature.rb +++ b/feature.rb @@ -19,7 +19,7 @@ class FeatureTest < Test::Unit::TestCase f = OpenTox::Feature.new(uri) f.load_metadata(@@subjectid) assert_not_nil f.metadata[DC.title] - assert_not_nil f.metadata[OT.hasSource] + #assert_not_nil f.metadata[OT.hasSource] end end diff --git a/lazar.rb b/lazar.rb index e2dd12a..eb8b99e 100644 --- a/lazar.rb +++ b/lazar.rb @@ -26,17 +26,16 @@ class LazarTest < Test::Unit::TestCase model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => @@regression_training_dataset.uri, :subjectid => @@subjectid}).to_s lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid @models << lazar - assert_equal 1356, lazar.features.size + assert_equal 185, lazar.features.size compound = OpenTox::Compound.from_smiles("c1ccccc1NN") prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid).to_s prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) @predictions << prediction - assert_equal prediction.value(compound).round_to(4), 0.17.round_to(4) - assert_equal prediction.confidence(compound).round_to(4), 0.5697.round_to(4) - assert_equal prediction.neighbors(compound).size, 77 + assert_equal prediction.value(compound).round_to(4), 0.3469.round_to(4) + assert_equal prediction.confidence(compound).round_to(4), 0.3223.round_to(4) + assert_equal prediction.neighbors(compound).size, 73 end - def test_classification_model # create model diff --git a/validate-owl.rb b/validate-owl.rb index 736531b..bfa2584 100644 --- a/validate-owl.rb +++ b/validate-owl.rb @@ -1,5 +1,3 @@ -#require 'nokogiri' - def validate_owl(uri, subjectid=nil) if validator_available? owl = OpenTox::RestClientWrapper.get(uri,{:accept => "application/rdf+xml",:subjectid => subjectid}) diff --git a/validation.rb b/validation.rb index ad9984e..aaab44f 100644 --- a/validation.rb +++ b/validation.rb @@ -301,9 +301,11 @@ class ValidationTest < Test::Unit::TestCase raise "no opentox object" unless opentox_object.class.to_s.split("::").first=="OpenTox" assert opentox_object.metadata.is_a?(Hash) assert opentox_object.metadata[DC.date].to_s.length>0,"date not set for "+opentox_object.uri.to_s+", is metadata loaded? (use find)" +=begin time = Time.parse(opentox_object.metadata[DC.date]) assert timeTime.new-(10*60),opentox_object.uri.to_s+" took longer than 10 minutes "+time.to_s +=end end # hack to have a global_setup and global_teardown -- cgit v1.2.3 From a640f0029ced0d247ac768529a6c4bf9563865a4 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Fri, 13 May 2011 11:30:12 +0200 Subject: fix validation tests for a&a enabled --- validation.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/validation.rb b/validation.rb index ad9984e..a685757 100644 --- a/validation.rb +++ b/validation.rb @@ -101,7 +101,7 @@ class ValidationTest < Test::Unit::TestCase assert v.uri.uri? if @@subjectid assert_rest_call_error OpenTox::NotAuthorizedError do - OpenTox::Crossvalidation.find(v.uri) + OpenTox::Validation.find(v.uri) end end v = OpenTox::Validation.find(v.uri, @@subjectid) @@ -126,7 +126,7 @@ class ValidationTest < Test::Unit::TestCase assert_kind_of OpenTox::Validation,v if @@subjectid assert_rest_call_error OpenTox::NotAuthorizedError do - OpenTox::CrossvalidationReport.create(v.uri) + OpenTox::ValidationReport.create(v.uri) end end report = OpenTox::ValidationReport.find_for_validation(v.uri,@@subjectid) @@ -135,7 +135,7 @@ class ValidationTest < Test::Unit::TestCase assert report.uri.uri? if @@subjectid assert_rest_call_error OpenTox::NotAuthorizedError do - OpenTox::CrossvalidationReport.find(report.uri) + OpenTox::ValidationReport.find(report.uri) end end report = OpenTox::ValidationReport.find(report.uri,@@subjectid) @@ -287,6 +287,7 @@ class ValidationTest < Test::Unit::TestCase begin yield rescue OpenTox::RestCallError => e + raise "error Report of RestCallError is no errorReport: "+e.errorCause.class.to_s+":\n"+e.errorCause.to_yaml unless e.errorCause.is_a?(OpenTox::ErrorReport) report = e.errorCause while report.errorCause report = report.errorCause -- cgit v1.2.3 From 14d04655b90b808c4f1468719f898cd0b3d59fe2 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 16 May 2011 11:20:23 +0200 Subject: authorization testing with turned off A&A in config --- authorization.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/authorization.rb b/authorization.rb index 3772638..cbe8b5a 100644 --- a/authorization.rb +++ b/authorization.rb @@ -3,6 +3,10 @@ require "opentox-ruby" require "test/unit" TEST_URI = "http://only_a_test/test/" + rand(1000000).to_s +unless AA_SERVER #overwrite turned off A&A server for testing + AA_SERVER = "https://opensso.in-silico.ch" + @@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) +end class TestOpenToxAuthorizationBasic < Test::Unit::TestCase @@ -104,4 +108,4 @@ end def login OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) -end \ No newline at end of file +end -- cgit v1.2.3 From 9e3c8678d895466939d7c4feb8d0a27fe030e01f Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 16 May 2011 11:36:26 +0200 Subject: fix in user groups test, test deleted policy --- authorization.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/authorization.rb b/authorization.rb index cbe8b5a..1d9b676 100644 --- a/authorization.rb +++ b/authorization.rb @@ -44,7 +44,7 @@ class TestOpenToxAuthorizationLDAP < Test::Unit::TestCase end def test_02_list_user_groups - assert_kind_of Array, OpenTox::Authorization.list_groups(@@subjectid) + assert_kind_of Array, OpenTox::Authorization.list_user_groups(TEST_USER, @@subjectid) end def test_03_get_user @@ -64,6 +64,7 @@ class TestOpenToxAuthorizationLDAP < Test::Unit::TestCase policies.each do |policy| assert OpenTox::Authorization.delete_policy(policy, @@subjectid) end + assert_equal false, OpenTox::Authorization.uri_has_policy(TEST_URI, @@subjectid) end def test_02_check_policy_rules -- cgit v1.2.3 From 4482a2dd9342a081d00849d059d1f37160df078b Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 17 May 2011 10:33:56 +0200 Subject: fix 202 wait on task, fix task.last to task.sort.last --- task.rb | 2 +- validate-owl.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/task.rb b/task.rb index 307d512..93aa8fb 100644 --- a/task.rb +++ b/task.rb @@ -20,7 +20,7 @@ class TaskTest < Test::Unit::TestCase def test_rdf - task = OpenTox::Task.new OpenTox::Task.all.last + task = OpenTox::Task.new OpenTox::Task.all.sort.last validate_owl(task.uri) #puts task.uri end diff --git a/validate-owl.rb b/validate-owl.rb index bfa2584..e219d58 100644 --- a/validate-owl.rb +++ b/validate-owl.rb @@ -1,6 +1,6 @@ def validate_owl(uri, subjectid=nil) if validator_available? - owl = OpenTox::RestClientWrapper.get(uri,{:accept => "application/rdf+xml",:subjectid => subjectid}) + owl = OpenTox::RestClientWrapper.get(uri,{:accept => "application/rdf+xml",:subjectid => subjectid}, nil, false) html = OpenTox::RestClientWrapper.post("http://www.mygrid.org.uk/OWL/Validator",{:rdf => owl, :level => "DL",:subjectid => subjectid}) assert_match(/YES/,html) else -- cgit v1.2.3