mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
fix(kg): resolve 'unhashable type: Entity' in GraphAnalyzer #159
- Robust ID extraction in CentralityCalculator, CommunityDetector, and ConnectivityAnalyzer - Support for direct Entity objects and dictionaries as node identifiers - Improved Entity hashability in utils/types.py - Added integration test to verify fix and prevent regression
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
|
||||
import unittest
|
||||
import tempfile
|
||||
import shutil
|
||||
import yaml
|
||||
from pathlib import Path
|
||||
from semantica.export.methods import export_yaml
|
||||
|
||||
class TestExportMethodsWrapper(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.test_dir = tempfile.mkdtemp()
|
||||
self.schema = {
|
||||
"uri": "http://example.org/schema",
|
||||
"classes": [{"id": "Person", "label": "Person"}],
|
||||
"properties": [{"id": "knows", "label": "Knows"}]
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.test_dir)
|
||||
|
||||
def test_export_yaml_schema(self):
|
||||
output_path = Path(self.test_dir) / "schema.yaml"
|
||||
|
||||
# This should call export_ontology_schema internally
|
||||
export_yaml(self.schema, str(output_path), method="schema")
|
||||
|
||||
self.assertTrue(output_path.exists())
|
||||
with open(output_path, 'r') as f:
|
||||
data = yaml.safe_load(f)
|
||||
self.assertEqual(data['ontology']['uri'], "http://example.org/schema")
|
||||
self.assertEqual(len(data['classes']), 1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user