From 65ac0d61fa363144906b761426e90c6b4a9b2c35 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Sat, 26 Oct 2024 09:29:36 +0200 Subject: [PATCH] Fix: Return search results as an object instead of a hash (#21) * return search results as an object instad of a hash * update test federated search to use search results as an object instead of a hash * fix tests timeout by using the dev server of biodivportal --------- Co-authored-by: Syphax --- config/config.test.rb | 2 +- lib/ontologies_api_client/models/class.rb | 2 +- test/models/test_federation.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config.test.rb b/config/config.test.rb index 1200719..f259b60 100644 --- a/config/config.test.rb +++ b/config/config.test.rb @@ -25,7 +25,7 @@ # color: '#1e2251', # }, biodivportal: { - api: 'https://data.biodivportal.gfbio.org/', + api: 'https://data.biodivportal.gfbio.dev/', apikey: "47a57aa3-7b54-4f34-b695-dbb5f5b7363e", color: '#1e2251', } diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index 6362c98..41895d5 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -83,7 +83,7 @@ def self.search(*args) merged_collections[:errors] << result.errors end end - merged_collections + OpenStruct.new(merged_collections) end diff --git a/test/models/test_federation.rb b/test/models/test_federation.rb index 600f2bf..5a9a147 100644 --- a/test/models/test_federation.rb +++ b/test/models/test_federation.rb @@ -124,14 +124,14 @@ def test_federated_search query = 'test' time1 = Benchmark.realtime do - @search_results = LinkedData::Client::Models::Class.search(query)[:collection] + @search_results = LinkedData::Client::Models::Class.search(query).collection end time2 = Benchmark.realtime do - @federated_search_results = LinkedData::Client::Models::Class.search(query, {federate: 'true'})[:collection] + @federated_search_results = LinkedData::Client::Models::Class.search(query, {federate: 'true'}).collection end - puts "Search results: #{@search_results .length} in #{time1}s" + puts "Search results: #{@search_results.length} in #{time1}s" puts "Federated search results: #{@federated_search_results.length} in #{time2}s" refute_equal @search_results.length, @federated_search_results.length