From 2b3faa2e52307a76ce25becfb4158ea6752fb870 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Sat, 18 Jul 2015 10:10:07 +0200 Subject: initial algorithm changes --- test/algorithm.rb | 7 ++++--- test/rest/urilist.rb | 26 ++++++++++++++++++++++++++ test/urilist.rb | 26 -------------------------- 3 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 test/rest/urilist.rb delete mode 100644 test/urilist.rb diff --git a/test/algorithm.rb b/test/algorithm.rb index 01ed930..8b76d47 100644 --- a/test/algorithm.rb +++ b/test/algorithm.rb @@ -12,10 +12,11 @@ class AlgorithmTest < MiniTest::Test def test_set_parameters a = OpenTox::Algorithm::Generic.new a.parameters = [ - {RDF::DC.title => "test", RDF::OT.paramScope => "mandatory"}, - {RDF::DC.title => "test2", RDF::OT.paramScope => "optional"} + {"title" => "test", "paramScope" => "mandatory"}, + {"title" => "test2", "paramScope" => "optional"} ] + p a assert_equal 2, a.parameters.size - assert_equal "mandatory", a.parameters.select{|p| p[RDF::DC.title] == "test"}.first[RDF::OT.paramScope] + assert_equal "mandatory", a.parameters.select{|p| p["title"] == "test"}.first["paramScope"] end end diff --git a/test/rest/urilist.rb b/test/rest/urilist.rb new file mode 100644 index 0000000..a269312 --- /dev/null +++ b/test/rest/urilist.rb @@ -0,0 +1,26 @@ +require_relative "setup.rb" + +class UriListTest < MiniTest::Test + + def test_01_urilist_duplicates + services = [$algorithm[:uri], $dataset[:uri], $feature[:uri], $model[:uri], $task[:uri]] + services.each do |service| + s_urilist = `curl -ik -H accept:text/uri-list #{service}`.split("\n") + assert_equal s_urilist.uniq.length, s_urilist.length, "Attention, duplicates found in #{service.split("/").last} uri-list!" + end + end + + def test_02_urilist_mime + # "application/rdf+xml", "text/turtle", "application/sparql-results+xml" are currently not supported and might lead to performance problem. I guess it is not worth the efforts to implement them at the moment, text/uri-list should be sufficient for most purposes (CH) + #mime_types = ["application/rdf+xml", "text/turtle", "application/sparql-results+xml", "text/plain", "text/uri-list", "text/html"] + mime_types = [ "text/plain","text/uri-list", "text/html"] + mime_types.each do |mt| + s_urilist = `curl -ik -H accept:#{mt} #{$feature[:uri]}` + #puts s_urilist + assert_match /200 OK/, s_urilist.to_s + refute_match /Content-Length: 0/, s_urilist.to_s, "Attention, content length empty!" + refute_match /dataset/, s_urilist.to_s, "Attention, found dataset in feature uri-list!" + end + end + +end diff --git a/test/urilist.rb b/test/urilist.rb deleted file mode 100644 index a269312..0000000 --- a/test/urilist.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative "setup.rb" - -class UriListTest < MiniTest::Test - - def test_01_urilist_duplicates - services = [$algorithm[:uri], $dataset[:uri], $feature[:uri], $model[:uri], $task[:uri]] - services.each do |service| - s_urilist = `curl -ik -H accept:text/uri-list #{service}`.split("\n") - assert_equal s_urilist.uniq.length, s_urilist.length, "Attention, duplicates found in #{service.split("/").last} uri-list!" - end - end - - def test_02_urilist_mime - # "application/rdf+xml", "text/turtle", "application/sparql-results+xml" are currently not supported and might lead to performance problem. I guess it is not worth the efforts to implement them at the moment, text/uri-list should be sufficient for most purposes (CH) - #mime_types = ["application/rdf+xml", "text/turtle", "application/sparql-results+xml", "text/plain", "text/uri-list", "text/html"] - mime_types = [ "text/plain","text/uri-list", "text/html"] - mime_types.each do |mt| - s_urilist = `curl -ik -H accept:#{mt} #{$feature[:uri]}` - #puts s_urilist - assert_match /200 OK/, s_urilist.to_s - refute_match /Content-Length: 0/, s_urilist.to_s, "Attention, content length empty!" - refute_match /dataset/, s_urilist.to_s, "Attention, found dataset in feature uri-list!" - end - end - -end -- cgit v1.2.3