summaryrefslogtreecommitdiff
path: root/test.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2009-07-21 18:24:36 +0200
committerChristoph Helma <helma@in-silico.de>2009-07-21 18:24:36 +0200
commit678a9667e25c5ca20338938474e39a3cdefa7c3e (patch)
tree7ac1d9d1ee838ea54dcfb35392bde1e17164b78a /test.rb
Initial import of opentox-dataset
Diffstat (limited to 'test.rb')
-rw-r--r--test.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test.rb b/test.rb
new file mode 100644
index 0000000..9d24a42
--- /dev/null
+++ b/test.rb
@@ -0,0 +1,46 @@
+ENV['RACK_ENV'] = 'test'
+require 'datasets'
+require 'test/unit'
+require 'rack/test'
+
+
+class DatasetsTest < Test::Unit::TestCase
+ include Rack::Test::Methods
+
+ def app
+ Sinatra::Application
+ end
+
+ def test_index
+ get '/'
+ assert last_response.ok?
+ end
+
+ def test_create_dataset
+ authorize "api", API_KEY
+ post '/', :dataset_name => "Test dataset"
+ assert last_response.ok?
+ assert_equal "http://example.org/1", last_response.body.chomp
+ end
+
+ def test_create_dataset_and_insert_data
+ authorize "api", API_KEY
+ post '/', :dataset_name => "Test dataset"
+ puts last_response.body
+ put '/1', :feature_name => "New feature", :feature_value => "inactive", :compound_name => 'Benzene'
+ puts last_response.body
+ put '/1', :feature_name => "New feature", :feature_value => "active", :compound_name => 'Dioxin'
+ get '/1'
+ puts last_response.body.chomp
+ assert last_response.ok?
+ end
+
+ def test_unauthorized_create
+ post '/', :dataset_name => "Test dataset", :feature_name => "Test feature", :file => File.new('tests/example.tab')
+ assert !last_response.ok?
+ end
+
+ def test_post_to_existing_dataset
+ end
+
+end