From 2d357889a2419586960c64844f2cb7beedcc3b38 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Mon, 16 Feb 2026 12:32:40 +0000 Subject: [PATCH] Lower case --- .../test_direct/test_entity_centric_kg.py | 76 +++++++++---------- .../test_triples_cassandra_storage.py | 8 +- .../trustgraph/direct/cassandra_kg.py | 14 ++-- .../query/triples/cassandra/service.py | 8 +- .../storage/triples/cassandra/write.py | 18 ++--- 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/unit/test_direct/test_entity_centric_kg.py b/tests/unit/test_direct/test_entity_centric_kg.py index af77dab1..5c07e6ab 100644 --- a/tests/unit/test_direct/test_entity_centric_kg.py +++ b/tests/unit/test_direct/test_entity_centric_kg.py @@ -93,7 +93,7 @@ class TestEntityCentricKnowledgeGraph: p='http://example.org/knows', o='http://example.org/Bob', g='http://example.org/graph1', - otype='U' + otype='u' ) # Verify batch was executed @@ -111,7 +111,7 @@ class TestEntityCentricKnowledgeGraph: p='http://www.w3.org/2000/01/rdf-schema#label', o='Alice Smith', g=None, - otype='L', + otype='l', dtype='xsd:string', lang='en' ) @@ -131,7 +131,7 @@ class TestEntityCentricKnowledgeGraph: p='http://example.org/knows', o='http://example.org/Bob', g=None, - otype='U' + otype='u' ) mock_session.execute.assert_called() @@ -169,7 +169,7 @@ class TestEntityCentricKnowledgeGraph: # Mock the query result mock_result = [ MagicMock(p='http://example.org/knows', o='http://example.org/Bob', - d='', otype='U', dtype='', lang='', s='http://example.org/Alice') + d='', otype='u', dtype='', lang='', s='http://example.org/Alice') ] mock_session.execute.return_value = mock_result @@ -190,7 +190,7 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(s='http://example.org/Alice', o='http://example.org/Bob', - d='', otype='U', dtype='', lang='', p='http://example.org/knows') + d='', otype='u', dtype='', lang='', p='http://example.org/knows') ] mock_session.execute.return_value = mock_result @@ -205,7 +205,7 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(s='http://example.org/Alice', p='http://example.org/knows', - d='', otype='U', dtype='', lang='', o='http://example.org/Bob') + d='', otype='u', dtype='', lang='', o='http://example.org/Bob') ] mock_session.execute.return_value = mock_result @@ -219,7 +219,7 @@ class TestEntityCentricKnowledgeGraph: kg, mock_session = entity_kg mock_result = [ - MagicMock(o='http://example.org/Bob', d='', otype='U', dtype='', lang='') + MagicMock(o='http://example.org/Bob', d='', otype='u', dtype='', lang='') ] mock_session.execute.return_value = mock_result @@ -234,7 +234,7 @@ class TestEntityCentricKnowledgeGraph: kg, mock_session = entity_kg mock_result = [ - MagicMock(s='http://example.org/Alice', d='', otype='U', dtype='', lang='', + MagicMock(s='http://example.org/Alice', d='', otype='u', dtype='', lang='', o='http://example.org/Bob') ] mock_session.execute.return_value = mock_result @@ -250,7 +250,7 @@ class TestEntityCentricKnowledgeGraph: kg, mock_session = entity_kg mock_result = [ - MagicMock(p='http://example.org/knows', d='', otype='U', dtype='', lang='', + MagicMock(p='http://example.org/knows', d='', otype='u', dtype='', lang='', s='http://example.org/Alice', o='http://example.org/Bob') ] mock_session.execute.return_value = mock_result @@ -266,7 +266,7 @@ class TestEntityCentricKnowledgeGraph: kg, mock_session = entity_kg mock_result = [ - MagicMock(d='', otype='U', dtype='', lang='', + MagicMock(d='', otype='u', dtype='', lang='', o='http://example.org/Bob') ] mock_session.execute.return_value = mock_result @@ -283,7 +283,7 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(s='http://example.org/Alice', p='http://example.org/knows', - o='http://example.org/Bob', otype='U', dtype='', lang='') + o='http://example.org/Bob', otype='u', dtype='', lang='') ] mock_session.execute.return_value = mock_result @@ -297,7 +297,7 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows', - o='http://example.org/Bob', otype='U', dtype='', lang='') + o='http://example.org/Bob', otype='u', dtype='', lang='') ] mock_session.execute.return_value = mock_result @@ -312,10 +312,10 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(p='http://example.org/knows', d='http://example.org/graph1', - otype='U', dtype='', lang='', s='http://example.org/Alice', + otype='u', dtype='', lang='', s='http://example.org/Alice', o='http://example.org/Bob'), MagicMock(p='http://example.org/knows', d='http://example.org/graph2', - otype='U', dtype='', lang='', s='http://example.org/Alice', + otype='u', dtype='', lang='', s='http://example.org/Alice', o='http://example.org/Charlie') ] mock_session.execute.return_value = mock_result @@ -331,10 +331,10 @@ class TestEntityCentricKnowledgeGraph: mock_result = [ MagicMock(p='http://example.org/knows', d='http://example.org/graph1', - otype='U', dtype='', lang='', s='http://example.org/Alice', + otype='u', dtype='', lang='', s='http://example.org/Alice', o='http://example.org/Bob'), MagicMock(p='http://example.org/knows', d='http://example.org/graph2', - otype='U', dtype='', lang='', s='http://example.org/Alice', + otype='u', dtype='', lang='', s='http://example.org/Alice', o='http://example.org/Charlie') ] mock_session.execute.return_value = mock_result @@ -384,7 +384,7 @@ class TestEntityCentricKnowledgeGraph: # Mock reading quads from collection mock_quads = [ MagicMock(d='', s='http://example.org/Alice', p='http://example.org/knows', - o='http://example.org/Bob', otype='U') + o='http://example.org/Bob', otype='u') ] mock_session.execute.return_value = mock_quads @@ -416,7 +416,7 @@ class TestQuadResult: p='http://example.org/knows', o='http://example.org/Bob', g='http://example.org/graph1', - otype='U', + otype='u', dtype='', lang='' ) @@ -425,7 +425,7 @@ class TestQuadResult: assert result.p == 'http://example.org/knows' assert result.o == 'http://example.org/Bob' assert result.g == 'http://example.org/graph1' - assert result.otype == 'U' + assert result.otype == 'u' assert result.dtype == '' assert result.lang == '' @@ -440,7 +440,7 @@ class TestQuadResult: g='' ) - assert result.otype == 'U' # Default otype + assert result.otype == 'u' # Default otype assert result.dtype == '' assert result.lang == '' @@ -453,12 +453,12 @@ class TestQuadResult: p='http://www.w3.org/2000/01/rdf-schema#label', o='Alice Smith', g='', - otype='L', + otype='l', dtype='xsd:string', lang='en' ) - assert result.otype == 'L' + assert result.otype == 'l' assert result.dtype == 'xsd:string' assert result.lang == 'en' @@ -511,42 +511,42 @@ class TestWriteHelperFunctions: """Test cases for helper functions in write.py""" def test_get_term_otype_for_iri(self): - """Test get_term_otype returns 'U' for IRI terms""" + """Test get_term_otype returns 'u' for IRI terms""" from trustgraph.storage.triples.cassandra.write import get_term_otype from trustgraph.schema import Term, IRI term = Term(type=IRI, iri='http://example.org/Alice') - assert get_term_otype(term) == 'U' + assert get_term_otype(term) == 'u' def test_get_term_otype_for_literal(self): - """Test get_term_otype returns 'L' for LITERAL terms""" + """Test get_term_otype returns 'l' for LITERAL terms""" from trustgraph.storage.triples.cassandra.write import get_term_otype from trustgraph.schema import Term, LITERAL term = Term(type=LITERAL, value='Alice Smith') - assert get_term_otype(term) == 'L' + assert get_term_otype(term) == 'l' def test_get_term_otype_for_blank(self): - """Test get_term_otype returns 'U' for BLANK terms""" + """Test get_term_otype returns 'u' for BLANK terms""" from trustgraph.storage.triples.cassandra.write import get_term_otype from trustgraph.schema import Term, BLANK term = Term(type=BLANK, id='_:b1') - assert get_term_otype(term) == 'U' + assert get_term_otype(term) == 'u' def test_get_term_otype_for_triple(self): - """Test get_term_otype returns 'T' for TRIPLE terms""" + """Test get_term_otype returns 't' for TRIPLE terms""" from trustgraph.storage.triples.cassandra.write import get_term_otype from trustgraph.schema import Term, TRIPLE term = Term(type=TRIPLE) - assert get_term_otype(term) == 'T' + assert get_term_otype(term) == 't' def test_get_term_otype_for_none(self): - """Test get_term_otype returns 'U' for None""" + """Test get_term_otype returns 'u' for None""" from trustgraph.storage.triples.cassandra.write import get_term_otype - assert get_term_otype(None) == 'U' + assert get_term_otype(None) == 'u' def test_get_term_dtype_for_literal(self): """Test get_term_dtype extracts datatype from LITERAL""" @@ -591,21 +591,21 @@ class TestServiceHelperFunctions: """Test cases for helper functions in service.py""" def test_create_term_with_uri_otype(self): - """Test create_term creates IRI Term for otype='U'""" + """Test create_term creates IRI Term for otype='u'""" from trustgraph.query.triples.cassandra.service import create_term from trustgraph.schema import IRI - term = create_term('http://example.org/Alice', otype='U') + term = create_term('http://example.org/Alice', otype='u') assert term.type == IRI assert term.iri == 'http://example.org/Alice' def test_create_term_with_literal_otype(self): - """Test create_term creates LITERAL Term for otype='L'""" + """Test create_term creates LITERAL Term for otype='l'""" from trustgraph.query.triples.cassandra.service import create_term from trustgraph.schema import LITERAL - term = create_term('Alice Smith', otype='L', dtype='xsd:string', lang='en') + term = create_term('Alice Smith', otype='l', dtype='xsd:string', lang='en') assert term.type == LITERAL assert term.value == 'Alice Smith' @@ -613,11 +613,11 @@ 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 IRI Term for otype='t'""" from trustgraph.query.triples.cassandra.service import create_term from trustgraph.schema import IRI - term = create_term('http://example.org/statement1', otype='T') + term = create_term('http://example.org/statement1', otype='t') assert term.type == IRI assert term.iri == 'http://example.org/statement1' diff --git a/tests/unit/test_storage/test_triples_cassandra_storage.py b/tests/unit/test_storage/test_triples_cassandra_storage.py index aa7a3383..e809485e 100644 --- a/tests/unit/test_storage/test_triples_cassandra_storage.py +++ b/tests/unit/test_storage/test_triples_cassandra_storage.py @@ -219,11 +219,11 @@ class TestCassandraStorageProcessor: assert mock_tg_instance.insert.call_count == 2 mock_tg_instance.insert.assert_any_call( 'collection1', 'subject1', 'predicate1', 'object1', - g=DEFAULT_GRAPH, otype='L', dtype='', lang='' + g=DEFAULT_GRAPH, otype='l', dtype='', lang='' ) mock_tg_instance.insert.assert_any_call( 'collection1', 'subject2', 'predicate2', 'object2', - g=DEFAULT_GRAPH, otype='L', dtype='', lang='' + g=DEFAULT_GRAPH, otype='l', dtype='', lang='' ) @pytest.mark.asyncio @@ -428,7 +428,7 @@ class TestCassandraStorageProcessor: 'predicate:with/colons', 'object with "quotes" and unicode: ñáéíóú', g=DEFAULT_GRAPH, - otype='L', + otype='l', dtype='', lang='' ) @@ -544,7 +544,7 @@ class TestCassandraPerformanceOptimizations: # Verify insert was called for the triple (implementation details tested in KnowledgeGraph) mock_tg_instance.insert.assert_called_once_with( 'collection1', 'test_subject', 'test_predicate', 'test_object', - g=DEFAULT_GRAPH, otype='L', dtype='', lang='' + g=DEFAULT_GRAPH, otype='l', dtype='', lang='' ) def test_environment_variable_controls_mode(self): diff --git a/trustgraph-flow/trustgraph/direct/cassandra_kg.py b/trustgraph-flow/trustgraph/direct/cassandra_kg.py index 20bd564a..3dc757cf 100644 --- a/trustgraph-flow/trustgraph/direct/cassandra_kg.py +++ b/trustgraph-flow/trustgraph/direct/cassandra_kg.py @@ -732,7 +732,7 @@ class EntityCentricKnowledgeGraph: p: Predicate (string value) o: Object (string value) g: Graph/dataset (None for default graph) - otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple) + otype: Object type - 'u' (URI), 'l' (literal), 't' (triple) Auto-detected from o value if not provided dtype: XSD datatype (for literals) lang: Language tag (for literals) @@ -744,9 +744,9 @@ class EntityCentricKnowledgeGraph: # Auto-detect otype if not provided (backwards compatibility) if otype is None: if o.startswith("http://") or o.startswith("https://"): - otype = "U" + otype = "u" else: - otype = "L" + otype = "l" batch = BatchStatement() @@ -761,7 +761,7 @@ class EntityCentricKnowledgeGraph: )) # Write row for object entity (role='O') - only for URIs, not literals - if otype == 'U' or otype == 'T': + if otype == 'u' or otype == 't': batch.add(self.insert_entity_stmt, ( collection, o, 'O', p, otype, s, o, g, dtype, lang )) @@ -1005,7 +1005,7 @@ class EntityCentricKnowledgeGraph: entities.add(p) # Object is an entity only for URIs - if otype == 'U' or otype == 'T': + if otype == 'u' or otype == 't': entities.add(o) # Graph is an entity for non-default graphs @@ -1073,12 +1073,12 @@ class QuadResult: p: Predicate value o: Object value g: Graph/dataset value - otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple) + otype: Object type - 'u' (URI), 'l' (literal), 't' (triple) dtype: XSD datatype (for literals) lang: Language tag (for literals) """ - def __init__(self, s, p, o, g, otype='U', dtype='', lang=''): + def __init__(self, s, p, o, g, otype='u', dtype='', lang=''): self.s = s self.p = p self.o = o diff --git a/trustgraph-flow/trustgraph/query/triples/cassandra/service.py b/trustgraph-flow/trustgraph/query/triples/cassandra/service.py index 7b85a87c..631d17f5 100755 --- a/trustgraph-flow/trustgraph/query/triples/cassandra/service.py +++ b/trustgraph-flow/trustgraph/query/triples/cassandra/service.py @@ -39,7 +39,7 @@ def create_term(value, otype=None, dtype=None, lang=None): Args: value: The string value - otype: Object type - 'U' (URI), 'L' (literal), 'T' (triple) + otype: Object type - 'u' (URI), 'l' (literal), 't' (triple) dtype: XSD datatype (for literals) lang: Language tag (for literals) @@ -47,16 +47,16 @@ def create_term(value, otype=None, dtype=None, lang=None): Otherwise falls back to URL detection heuristic. """ if otype is not None: - if otype == 'U': + if otype == 'u': return Term(type=IRI, iri=value) - elif otype == 'L': + elif otype == 'l': return Term( type=LITERAL, value=value, datatype=dtype or "", language=lang or "" ) - elif otype == 'T': + elif otype == 't': # Triple/reification - treat as IRI for now return Term(type=IRI, iri=value) else: diff --git a/trustgraph-flow/trustgraph/storage/triples/cassandra/write.py b/trustgraph-flow/trustgraph/storage/triples/cassandra/write.py index 5d1e160b..3c676d41 100755 --- a/trustgraph-flow/trustgraph/storage/triples/cassandra/write.py +++ b/trustgraph-flow/trustgraph/storage/triples/cassandra/write.py @@ -43,21 +43,21 @@ def get_term_otype(term): Get object type code from a Term for entity-centric storage. Maps Term.type to otype: - - IRI ("i") → "U" (URI) - - BLANK ("b") → "U" (treated as URI) - - LITERAL ("l") → "L" (Literal) - - TRIPLE ("t") → "T" (Triple/reification) + - IRI ("i") → "u" (URI) + - BLANK ("b") → "u" (treated as URI) + - LITERAL ("l") → "l" (Literal) + - TRIPLE ("t") → "t" (Triple/reification) """ if term is None: - return "U" + return "u" if term.type == IRI or term.type == BLANK: - return "U" + return "u" elif term.type == LITERAL: - return "L" + return "l" elif term.type == TRIPLE: - return "T" + return "t" else: - return "U" + return "u" def get_term_dtype(term):