summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2013-12-03 19:36:20 +0100
committerrautenberg <rautenberg@in-silico.ch>2013-12-03 19:36:20 +0100
commitce65fa9a1dd28d7642cb0c957bbff91d9bf9bcb5 (patch)
tree7d4e5552908fc6051160db04e7615b6c4a752c16
parent90208a192f406c469975b10149be947bac3211f3 (diff)
add tests for investigation data sparql templates
-rw-r--r--test/toxbank-investigation-sparql.rb75
1 files changed, 70 insertions, 5 deletions
diff --git a/test/toxbank-investigation-sparql.rb b/test/toxbank-investigation-sparql.rb
index 0adc2e6..bf181a0 100644
--- a/test/toxbank-investigation-sparql.rb
+++ b/test/toxbank-investigation-sparql.rb
@@ -1,7 +1,7 @@
require_relative "toxbank-setup.rb"
# Test API extension SPARQL templates
-class TBSPARQLTest < MiniTest::Test
+class TBSPARQLTest < Minitest::Unit::TestCase
# login as pi and create a test investigation
def setup
@@ -18,17 +18,82 @@ class TBSPARQLTest < MiniTest::Test
end
# initial tests to be changed
- def test_01_initial_nonexisting_template
+ def test_nonexisting_template
assert_raises OpenTox::ResourceNotFoundError do
- response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/not_existing_template", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid]}
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/not_existing_template", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
end
end
- def test_02_initial_existing_template
- response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/investigation_details", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid]}
+ def test_existing_template
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/investigation_details", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
assert_equal 200, response.code
end
+ def test_camelcase_template
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/InvestigationDetails", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
+ assert_equal 200, response.code
+ end
+
+ def test_factors_by_investigation
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/factors_by_investigation", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
+ result = JSON.parse(response)
+ factorvalues = result["results"]["bindings"].map {|n| "#{n["factorname"]["value"]}:::#{n["value"]["value"]}"}
+ assert factorvalues.include?("limiting nutrient:::phosphorus")
+ assert factorvalues.include?("limiting nutrient:::glucose")
+ assert factorvalues.include?("limiting nutrient:::carbon")
+ assert factorvalues.include?("limiting nutrient:::sulfur")
+ assert factorvalues.include?("limiting nutrient:::nitrogen")
+ assert factorvalues.include?("limiting nutrient:::ethanol")
+ assert factorvalues.include?("rate:::0.1")
+ assert factorvalues.include?("rate:::0.2")
+ assert factorvalues.include?("rate:::0.07")
+ end
+
+ def test_characteristics_by_investigation
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/characteristics_by_investigation", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
+ result = JSON.parse(response)
+ propnamevalues = result["results"]["bindings"].map {|n| "#{n["propname"]["value"]}:::#{n["value"]["value"]}:::#{n["ontouri"]["value"]}"}
+ assert propnamevalues.include?("organism:::Saccharomyces cerevisiae (Baker's yeast):::http://purl.obolibrary.org/obo/NEWT_4932")
+ assert propnamevalues.include?("Label:::biotin:::http://purl.obolibrary.org/chebi/15956")
+ assert propnamevalues.include?("organism:::Saccharomyces cerevisiae (Baker's yeast):::http://purl.obolibrary.org/obo/NEWT_4932")
+ end
+
+
+ def test_investigation_endpoint_technology
+ response = OpenTox::RestClientWrapper.get "#{@@uri}/sparql/investigation_endpoint_technology", {}, {:accept => "application/json", :subjectid => $pi[:subjectid]}
+ result = JSON.parse(response)
+ endpointtechnologies = result["results"]["bindings"].map {|n| "#{n["endpoint"]["value"]}:::#{n["technology"]["value"]}"}
+ assert_equal endpointtechnologies.size, 4
+ end
+
+ def test_investigation_and_characteristics
+ end
+
+ def test_investigations_and_protocols
+ end
+
+ def test_investigations_and_factors
+ end
+
+ def test_protocols_by_factors
+ end
+
+ def test_invetsigation_by_factors
+ end
+
+ def test_investigation_by_factorend
+ end
+
+ def test_investigation_by_characteristic_valueend
+ end
+
+ def test_investigation_by_characteristic_name
+ end
+
+ def test_investigation_by_characteristic
+ end
+
+
# delete investigation/{id}
# @note expect code 200
def teardown