diff --git a/tests/unit/test_direct/test_entity_centric_kg.py b/tests/unit/test_direct/test_entity_centric_kg.py index 5f64b581..df70efee 100644 --- a/tests/unit/test_direct/test_entity_centric_kg.py +++ b/tests/unit/test_direct/test_entity_centric_kg.py @@ -569,14 +569,24 @@ class TestServiceHelperFunctions: assert term.language == 'en' def test_create_term_with_triple_otype(self): - """Test create_term creates IRI Term for otype='t'""" + """Test create_term creates TRIPLE Term for otype='t' with valid JSON""" from trustgraph.query.triples.cassandra.service import create_term - from trustgraph.schema import IRI + from trustgraph.schema import TRIPLE, IRI + import json - term = create_term('http://example.org/statement1', otype='t') + # Valid JSON triple data + triple_json = json.dumps({ + "s": {"type": "i", "iri": "http://example.org/Alice"}, + "p": {"type": "i", "iri": "http://example.org/knows"}, + "o": {"type": "i", "iri": "http://example.org/Bob"}, + }) - assert term.type == IRI - assert term.iri == 'http://example.org/statement1' + term = create_term(triple_json, otype='t') + + assert term.type == TRIPLE + assert term.triple is not None + assert term.triple.s.type == IRI + assert term.triple.s.iri == "http://example.org/Alice" def test_create_term_heuristic_fallback_uri(self): """Test create_term uses URL heuristic when otype not provided""" diff --git a/tests/unit/test_storage/test_graph_embeddings_milvus_storage.py b/tests/unit/test_storage/test_graph_embeddings_milvus_storage.py index 8a8e1090..ebb93b62 100644 --- a/tests/unit/test_storage/test_graph_embeddings_milvus_storage.py +++ b/tests/unit/test_storage/test_graph_embeddings_milvus_storage.py @@ -172,26 +172,30 @@ class TestMilvusGraphEmbeddingsStorageProcessor: message.metadata = MagicMock() message.metadata.user = 'test_user' message.metadata.collection = 'test_collection' - + valid_entity = EntityEmbeddings( entity=Term(type=IRI, iri='http://example.com/valid'), - vectors=[[0.1, 0.2, 0.3]] + vectors=[[0.1, 0.2, 0.3]], + chunk_id='' ) empty_entity = EntityEmbeddings( entity=Term(type=LITERAL, value=''), - vectors=[[0.4, 0.5, 0.6]] + vectors=[[0.4, 0.5, 0.6]], + chunk_id='' ) none_entity = EntityEmbeddings( entity=Term(type=LITERAL, value=None), - vectors=[[0.7, 0.8, 0.9]] + vectors=[[0.7, 0.8, 0.9]], + chunk_id='' ) message.entities = [valid_entity, empty_entity, none_entity] - + await processor.store_graph_embeddings(message) - - # Verify only valid entity was inserted with user/collection parameters + + # Verify only valid entity was inserted with user/collection/chunk_id parameters processor.vecstore.insert.assert_called_once_with( - [0.1, 0.2, 0.3], 'http://example.com/valid', 'test_user', 'test_collection' + [0.1, 0.2, 0.3], 'http://example.com/valid', 'test_user', 'test_collection', + chunk_id='' ) @pytest.mark.asyncio