From 0163a39a2b186c5ca0c3358d0e61b16ca477208b Mon Sep 17 00:00:00 2001 From: rautenberg Date: Wed, 3 Jun 2015 12:42:53 +0200 Subject: add tests for available formats, API file and check if swagger json is valid --- test/compound.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 -- cgit v1.2.3