Select Git revision
webpack.config.js
test_ontology_submodules.py 3.34 KiB
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# test_ontology_modules: Ontology Modules Testing
#------------------------------------------------------------------------------
# Contains tests for verifying functionality of the ontology submodules.
#==============================================================================
import unittest
from rdflib import URIRef
# Importing necessary modules from the ontoScorer package for testing.
from context import ontoScorer
from ontoScorer.ontology_axioms import *
from ontoScorer.ontology_nontaxonomic_relations import *
from ontoScorer.ontology_taxonomic_relations import *
#--------------------------------------------------------------------------
# Ontology Taxonomic Relations Test
#--------------------------------------------------------------------------
class TestOntologyTaxonomicRelations(unittest.TestCase):
def setUp(self):
# Any necessary setup can be done here...
pass
def test_subclass_of_relation(self):
relation = SubclassOfRelation(URIRef("http://example.com#Subclass"), URIRef("http://example.com#Superclass"), None)
self.assertEqual(str(relation), "http://example.com#Subclass is a subclass of http://example.com#Superclass")
# Additional test methods for other taxonomic relations can be added here...
#--------------------------------------------------------------------------
# Ontology Non-Taxonomic Relations Test
#--------------------------------------------------------------------------
class TestOntologyNonTaxonomicRelations(unittest.TestCase):
def setUp(self):
# Any necessary setup can be done here...
pass
def test_object_property_relation(self):
relation = ObjectPropertyRelation(URIRef("http://example.com#Source"), URIRef("http://example.com#Target"), None)
self.assertEqual(str(relation), "http://example.com#Source has object property http://example.com#Target")
# Additional test methods for other non-taxonomic relations can be added here...
#--------------------------------------------------------------------------
# Ontology Axioms Test
#--------------------------------------------------------------------------
class TestOntologyAxioms(unittest.TestCase):
def setUp(self):
# Any necessary setup can be done here...
pass
def test_restriction_axiom(self):
axiom = RestrictionAxiom(URIRef("http://example.com#SomeClass"))
self.assertEqual(str(axiom), "Restriction on: http://example.com#SomeClass")
def test_some_values_from_restriction(self):
restriction_node = BNode()
on_property = URIRef("http://example.org/hasPart")
some_values_from = URIRef("http://example.org/Hand")
restriction = SomeValuesFromRestrictionAxiom(restriction_node, on_property, some_values_from)
self.assertEqual(str(restriction), "Restriction on: {} via property: http://example.org/hasPart with some values from: http://example.org/Hand".format(restriction_node))
# Additional test methods for other axiom types can be added here...
#--------------------------------------------------------------------------
# Main Unit Test Run
#--------------------------------------------------------------------------
if __name__ == "__main__":
unittest.main()