-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
11 changed files
with
201 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ Ontology: | |
Annotations: rdfs:label "ClassB" | ||
SubClassOf: :A | ||
Class: :C | ||
Class: :D | ||
SubClassOf: :B |
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ Ontology: | |
Annotations: rdfs:label "ClassB" | ||
SubClassOf: :A | ||
Class: :C | ||
Class: :D | ||
SubClassOf: :B |
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,89 @@ | ||
import unittest | ||
|
||
from test_base import simple_ontology | ||
|
||
|
||
class HierarchyTestCase(unittest.TestCase): | ||
def test_no_subclass(self): | ||
o = simple_ontology() | ||
|
||
expected = set() | ||
actual = o.get_subclasses(":C") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_no_superclass(self): | ||
o = simple_ontology() | ||
|
||
expected = set() | ||
actual = o.get_superclasses(":C") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_direct_subclass(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/B"} | ||
actual = o.get_subclasses(":A") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_direct_superclass(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/A"} | ||
actual = o.get_superclasses(":B") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_no_ancestors(self): | ||
o = simple_ontology() | ||
|
||
expected = set() | ||
actual = o.get_ancestors(":A") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_no_descendants(self): | ||
o = simple_ontology() | ||
|
||
expected = set() | ||
actual = o.get_descendants(":C") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_single_ancestors(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/A"} | ||
actual = o.get_ancestors(":B") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_single_descendants(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/D"} | ||
actual = o.get_descendants(":B") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_multiple_ancestors(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/A", "https://example.com/B"} | ||
actual = o.get_ancestors(":D") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
def test_multiple_descendants(self): | ||
o = simple_ontology() | ||
|
||
expected = {"https://example.com/B", "https://example.com/D"} | ||
actual = o.get_descendants(":A") | ||
|
||
self.assertSetEqual(expected, actual) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |