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.
Feature: Add class level explorer to avoid unnecessary calls (#25)
* add class level explorer to avoid unnecessary calls * add link explorer tests * add link explorer forwarding * optimize the top level links call to be done only once * fix test after making top_level_links class variable
- Loading branch information
1 parent
2e02a09
commit 23ae179
Showing
6 changed files
with
97 additions
and
22 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
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,2 @@ | ||
[tools] | ||
ruby = "2.7.8" |
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,45 @@ | ||
require_relative '../test_case' | ||
require 'pry' | ||
|
||
module Models | ||
def self.method_missing | ||
binding.pry | ||
end | ||
end | ||
class LinkExploreTest < LinkedData::Client::TestCase | ||
|
||
def test_explore | ||
sub_direct_explore = LinkedData::Client::Models::Ontology.explore('MEDDRA') | ||
.latest_submission | ||
.get(include: 'all') | ||
|
||
sub_indirect_explore = LinkedData::Client::Models::Ontology.find('MEDDRA').explore.latest_submission | ||
sub_direct_explore.to_hash.each do |key, value| | ||
value_to_compare = sub_indirect_explore[key] | ||
if value.class.ancestors.include?(LinkedData::Client::Base) | ||
value = value.to_hash | ||
value_to_compare = value_to_compare.to_hash | ||
end | ||
assert_equal value, value_to_compare | ||
end | ||
end | ||
|
||
def test_explore_class | ||
|
||
id = 'http://purl.org/sig/ont/fma/fma62955' | ||
cls = LinkedData::Client::Models::Ontology.explore('FMA') | ||
.classes(id) | ||
.children | ||
.get | ||
|
||
assert_not_empty cls.collection | ||
|
||
cls = LinkedData::Client::Models::Ontology.explore('FMA') | ||
.classes(id) | ||
.children | ||
.get(include: 'prefLabel') | ||
|
||
assert_not_empty cls.collection | ||
end | ||
|
||
end |