From e5b63460933112573a4e5ed1f2825c9267370ce0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 17 Aug 2009 11:04:41 +0200 Subject: lazar prediction class added, tests finished --- test/opentox-ruby-api-wrapper_test.rb | 46 +++++++++++------------------------ test/start-local-webservices.rb | 13 ++++++++++ 2 files changed, 27 insertions(+), 32 deletions(-) create mode 100755 test/start-local-webservices.rb (limited to 'test') diff --git a/test/opentox-ruby-api-wrapper_test.rb b/test/opentox-ruby-api-wrapper_test.rb index 256a06a..6b09c4a 100644 --- a/test/opentox-ruby-api-wrapper_test.rb +++ b/test/opentox-ruby-api-wrapper_test.rb @@ -3,62 +3,44 @@ require 'test_helper' class OpentoxRubyApiWrapperTest < Test::Unit::TestCase def setup - @pids = [] - port = 5000 - [ "opentox-compound", "opentox-feature" , "opentox-dataset" , "opentox-fminer" , "opentox-lazar" ].each do |component| - ENV[component.upcase.gsub(/-/,'_')] = "http://localhost:#{port}/" -=begin - Dir.chdir ENV['HOME'] + '/webservices/' + component - Dir["test.sqlite3"].each { |f| FileUtils.rm_rf(f) } - file = 'application.rb' - @pids << fork {`urxvt -title #{component} -e thin --debug --rackup config.ru start -p #{port} -e test`} - Process.detach(@pids.last) -=end - port += 1 - end - end - -=begin - def teardown - @pids.each do |pid| - begin - Process.kill(9,pid) - puts "killed " + pid.to_s - rescue - puts "failed to kill process" + pid.to_s + if ENV['LOCAL'] + port = 5000 + [ "opentox-compound", "opentox-feature" , "opentox-dataset" , "opentox-fminer" , "opentox-lazar" ].each do |component| + ENV[component.upcase.gsub(/-/,'_')] = "http://localhost:#{port}/" + port += 1 end end end -=end def test_create_dataset_and_model_and_make_a_prediction - #sleep 15 dataset = OpenTox::Dataset.new :name => "Hamster Carcinogenicity", :filename => "test/hamster_carcinogenicity.csv" puts dataset.uri wait_for_completion dataset assert_match(/#{ENV['OPENTOX_DATASET']}\d+$/,dataset.uri) assert_equal("Hamster Carcinogenicity",dataset.name) + assert_equal(true,dataset.finished?) lazar = OpenTox::Lazar.new :dataset_uri => dataset.uri puts lazar.uri wait_for_completion lazar + assert_equal(true,lazar.finished?) assert_match(/#{ENV['OPENTOX_LAZAR']}model\/\d+$/,lazar.uri) query_structure = OpenTox::Compound.new :smiles => 'c1ccccc1NN' + puts query_structure.uri prediction = lazar.predict query_structure puts prediction.uri wait_for_completion prediction - puts prediction.to_yaml + puts prediction.classification + puts prediction.confidence + puts prediction.neighbors + puts prediction.features assert_equal(true, prediction.classification) - assert_match(/\d+/, prediction.classification) + assert_match(/0\.\d+/, prediction.confidence.to_s) end end def wait_for_completion(object) - timeout = 60 - time = 0 - while (!object.finished? and time < timeout) + while (!object.finished?) sleep 1 - time += 1 end - puts "timeout" if timeout >= 60 end diff --git a/test/start-local-webservices.rb b/test/start-local-webservices.rb new file mode 100755 index 0000000..66dea29 --- /dev/null +++ b/test/start-local-webservices.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby +require 'fileutils' + +port = 5000 +[ "opentox-compound", "opentox-feature" , "opentox-dataset" , "opentox-fminer" , "opentox-lazar" ].each do |component| + ENV[component.upcase.gsub(/-/,'_')] = "http://localhost:#{port}/" + Dir.chdir ENV['HOME'] + '/webservices/' + component + Dir["test.sqlite3"].each { |f| FileUtils.rm_rf(f) } + file = 'application.rb' + pid = fork {`urxvt -title #{component} -e thin --debug --rackup config.ru start -p #{port} -e test`} + Process.detach(pid) + port += 1 +end -- cgit v1.2.3