Integration tests pass

This commit is contained in:
Cyber MacGeddon 2025-09-30 13:49:39 +01:00
parent 48ac9960a7
commit b5bdc21cee

View file

@ -86,7 +86,8 @@ class TestObjectsCassandraIntegration:
processor.convert_value = Processor.convert_value.__get__(processor, Processor)
processor.on_schema_config = Processor.on_schema_config.__get__(processor, Processor)
processor.on_object = Processor.on_object.__get__(processor, Processor)
processor.create_collection = Processor.create_collection.__get__(processor, Processor)
return processor, mock_cassandra_cluster, mock_cassandra_session
@pytest.mark.asyncio
@ -261,6 +262,9 @@ class TestObjectsCassandraIntegration:
]
)
# Create collection first
await processor.create_collection("test", "test")
# Create object missing required field
test_obj = ExtractedObject(
metadata=Metadata(id="t1", user="test", collection="test", metadata=[]),
@ -269,10 +273,10 @@ class TestObjectsCassandraIntegration:
confidence=0.8,
source_span="Test"
)
msg = MagicMock()
msg.value.return_value = test_obj
# Should still process (Cassandra doesn't enforce NOT NULL)
await processor.on_object(msg, None, None)
@ -297,6 +301,9 @@ class TestObjectsCassandraIntegration:
]
)
# Create collection first
await processor.create_collection("logger", "app_events")
# Process object
test_obj = ExtractedObject(
metadata=Metadata(id="e1", user="logger", collection="app_events", metadata=[]),
@ -305,10 +312,10 @@ class TestObjectsCassandraIntegration:
confidence=1.0,
source_span="Event"
)
msg = MagicMock()
msg.value.return_value = test_obj
await processor.on_object(msg, None, None)
# Verify synthetic_id was added
@ -397,7 +404,11 @@ class TestObjectsCassandraIntegration:
# Process objects from different collections
collections = ["import_jan", "import_feb", "import_mar"]
# Create all collections first
for coll in collections:
await processor.create_collection("analytics", coll)
for coll in collections:
obj = ExtractedObject(
metadata=Metadata(id=f"{coll}-1", user="analytics", collection=coll, metadata=[]),
@ -406,7 +417,7 @@ class TestObjectsCassandraIntegration:
confidence=0.9,
source_span="Data"
)
msg = MagicMock()
msg.value.return_value = obj
await processor.on_object(msg, None, None)
@ -474,9 +485,12 @@ class TestObjectsCassandraIntegration:
source_span="Multiple customers extracted from document"
)
# Create collection first
await processor.create_collection("test_user", "batch_import")
msg = MagicMock()
msg.value.return_value = batch_obj
await processor.on_object(msg, None, None)
# Verify table creation
@ -517,6 +531,9 @@ class TestObjectsCassandraIntegration:
fields=[Field(name="id", type="string", size=50, primary=True)]
)
# Create collection first
await processor.create_collection("test", "empty")
# Process empty batch object
empty_obj = ExtractedObject(
metadata=Metadata(id="empty-1", user="test", collection="empty", metadata=[]),
@ -525,10 +542,10 @@ class TestObjectsCassandraIntegration:
confidence=1.0,
source_span="No objects found"
)
msg = MagicMock()
msg.value.return_value = empty_obj
await processor.on_object(msg, None, None)
# Should still create table
@ -555,6 +572,9 @@ class TestObjectsCassandraIntegration:
]
)
# Create collection first
await processor.create_collection("test", "mixed")
# Single object (backward compatibility)
single_obj = ExtractedObject(
metadata=Metadata(id="single", user="test", collection="mixed", metadata=[]),
@ -563,7 +583,7 @@ class TestObjectsCassandraIntegration:
confidence=0.9,
source_span="Single object"
)
# Batch object
batch_obj = ExtractedObject(
metadata=Metadata(id="batch", user="test", collection="mixed", metadata=[]),
@ -575,7 +595,7 @@ class TestObjectsCassandraIntegration:
confidence=0.85,
source_span="Batch objects"
)
# Process both
for obj in [single_obj, batch_obj]:
msg = MagicMock()