summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2015-06-03 12:42:53 +0200
committerrautenberg <rautenberg@in-silico.ch>2015-06-03 12:42:53 +0200
commit0163a39a2b186c5ca0c3358d0e61b16ca477208b (patch)
treedec8e165a868e345b3e98d7e381179cebce3aa0b
parent66cdb8f36109502a699c37856f83ba9df22adf35 (diff)
add tests for available formats, API file and check if swagger json is valid
-rw-r--r--test/compound.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/compound.rb b/test/compound.rb
index 47a0aed..21758af 100644
--- a/test/compound.rb
+++ b/test/compound.rb
@@ -76,3 +76,32 @@ class CompoundTest < MiniTest::Test
end
end
+
+class CompoundServiceTest < MiniTest::Test
+
+ def test_formats # test supported formats from service
+ formats = ["chemical/x-daylight-smiles", "chemical/x-inchi", "chemical/x-mdl-sdfile", "chemical/x-mdl-molfile", "image/png", "text/html"]
+ formats.each do |format|
+ response = OpenTox::RestClientWrapper.get "#{$compound[:uri]}/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H", {}, { :accept => format }
+ assert_equal format, response.headers[:content_type]
+ assert_equal 200, response.code
+ end
+ end
+
+end
+
+class CompoundAPITest < MiniTest::Test
+
+ def test_apifile # test if api file is present
+ format = "application/json"
+ response = OpenTox::RestClientWrapper.get "#{$compound[:uri]}/api/compound.json", {}, { :accept => format }
+ assert_equal format, response.headers[:content_type]
+ assert_equal 200, response.code
+ end
+
+ def test_swagger_valid
+ res = OpenTox::RestClientWrapper.get "http://online.swagger.io/validator/debug?url=#{$compound[:uri]}/api/compound.json"
+ assert_equal res, "[]", "Swagger API document #{$compound[:uri]}/api/compound.json is not valid: \n#{res}"
+ end
+
+end