Fix tests (#663)

This commit is contained in:
cybermaggedon 2026-03-06 12:40:02 +00:00 committed by GitHub
parent 2b9232917c
commit be358efe67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 13 deletions

View file

@ -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"""

View file

@ -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