forked from ontoportal/ontologies_api_ruby_client
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fff5453
commit e5a18ff
Showing
11 changed files
with
178 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
# config.rb is required for testing | ||
# unit test makes calls to bioportal api so it needs a valid API key which can | ||
# be set via ENV variable UT_APIKEY | ||
abort('UT_APIKEY env variable is not set. Canceling tests') unless ENV.include?('UT_APIKEY') | ||
abort('UT_APIKEY env variable is set to an empty value. Canceling tests') unless ENV['UT_APIKEY'].size > 5 | ||
ENV['UT_APIKEY'] = '1de0a270-29c5-4dda-b043-7c3580628cd5' | ||
$API_CLIENT_INVALIDATE_CACHE = false | ||
$DEBUG_API_CLIENT = false | ||
|
||
LinkedData::Client.config do |config| | ||
config.rest_url = 'https://data.bioontology.org' | ||
config.apikey = ENV['UT_APIKEY'] | ||
# config.apikey = 'xxxxx-xxxxx-xxxxxxxxxx' | ||
config.rest_url = 'https://data.agroportal.lirmm.fr/' | ||
config.apikey = '1de0a270-29c5-4dda-b043-7c3580628cd5' | ||
config.links_attr = 'links' | ||
config.cache = false | ||
config.cache = true | ||
config.debug_client = true | ||
config.debug_client_keys = [] | ||
config.federated_portals = { | ||
bioportal: { | ||
api: 'https://data.bioontology.org/', | ||
apikey: '8b5b7825-538d-40e0-9e9e-5ab9274a9aeb', | ||
color: '#234979', | ||
}, | ||
ecoportal: { | ||
api: 'https://data.ecoportal.lifewatch.eu/', | ||
apikey: "43a437ba-a437-4bf0-affd-ab520e584719", | ||
color: '#0f4e8a', | ||
}, | ||
earthportal: { | ||
api: 'https://earthportal.eu:8443/', | ||
apikey: "c9147279-954f-41bd-b068-da9b0c441288", | ||
color: '#1e2251', | ||
}, | ||
biodivportal: { | ||
api: 'https://data.biodivportal.gfbio.org/', | ||
apikey: "47a57aa3-7b54-4f34-b695-dbb5f5b7363e", | ||
color: '#1e2251', | ||
} | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require_relative '../test_case' | ||
require 'pry' | ||
require 'benchmark' | ||
|
||
class FederationTest < LinkedData::Client::TestCase | ||
|
||
def test_cache | ||
onts = LinkedData::Client::Models::Ontology.all | ||
onts = LinkedData::Client::Models::Ontology.all | ||
end | ||
|
||
def test_federated_ontologies_all | ||
onts = [] | ||
time1 = Benchmark.realtime do | ||
onts = LinkedData::Client::Models::Ontology.all | ||
end | ||
|
||
onts_federate = [] | ||
time2 = Benchmark.realtime do | ||
onts_federate = LinkedData::Client::Models::Ontology.all(federate: true) | ||
end | ||
|
||
puts "" | ||
puts "AgroPortal ontologies: #{onts.length} in #{time1}s" | ||
puts "Federated ontologies: #{onts_federate.length} in #{time2}s" | ||
|
||
refute_equal onts.length, onts_federate.length | ||
|
||
onts_federate.group_by{|x| x.id.split('/')[0..-2].join('/')}.each do |portal, onts| | ||
puts "#{portal} ontologies: #{onts.length}" | ||
end | ||
|
||
onts_federate = [] | ||
time2 = Benchmark.realtime do | ||
onts_federate = LinkedData::Client::Models::Ontology.all(federate: true) | ||
end | ||
puts "Federated ontologies with cache: #{onts_federate.length} in #{time2}s" | ||
end | ||
|
||
def test_federated_submissions_all | ||
onts = [] | ||
time1 = Benchmark.realtime do | ||
onts = LinkedData::Client::Models::OntologySubmission.all | ||
end | ||
|
||
onts_federate = [] | ||
time2 = Benchmark.realtime do | ||
onts_federate = LinkedData::Client::Models::OntologySubmission.all(federate: true) | ||
end | ||
|
||
puts "" | ||
puts "AgroPortal submissions: #{onts.length} in #{time1}s" | ||
puts "Federated submissions: #{onts_federate.length} in #{time2}s" | ||
|
||
refute_equal onts.length, onts_federate.length | ||
|
||
onts_federate.group_by{|x| x.id.split('/')[0..-4].join('/')}.each do |portal, onts| | ||
puts "#{portal} submissions: #{onts.length}" | ||
end | ||
|
||
onts_federate = [] | ||
time2 = Benchmark.realtime do | ||
onts_federate = LinkedData::Client::Models::OntologySubmission.all(federate: true) | ||
end | ||
puts "Federated submissions with cache: #{onts_federate.length} in #{time2}s" | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.