blob: 5f1db3f5ed5c5681b78f6ec8c41fe623ec8d7dcd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
require "rubygems"
require "sinatra"
before {
request.env['HTTP_HOST']="local-ot/dataset"
request.env["REQUEST_URI"]=request.env["PATH_INFO"]
}
require "opentox-ruby"
ENV['RACK_ENV'] = 'test'
require 'application.rb'
require 'test/unit'
require 'rack/test'
LOGGER = Logger.new(STDOUT)
LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S "
module Sinatra
set :raise_errors, false
set :show_exceptions, false
module UrlForHelper
BASE = "http://local-ot/dataset"
def url_for url_fragment, mode=:path_only
case mode
when :path_only
raise "not impl"
when :full
end
"#{BASE}#{url_fragment}"
end
end
end
class DatasetTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_sth
begin
#http://local-ot/dataset/452
#http://local-ot/dataset/453
get '/504',nil,'HTTP_ACCEPT' => "text/arff"
puts last_response.body
#delete '/cleanup'
#puts last_response.body
rescue => ex
rep = OpenTox::ErrorReport.create(ex, "")
puts rep.to_yaml
end
end
# see test_util.rb
def wait_for_task(uri)
if uri.task_uri?
task = OpenTox::Task.find(uri)
task.wait_for_completion
raise "task failed: "+uri.to_s if task.error?
uri = task.result_uri
end
return uri
end
end
|