More tests

This commit is contained in:
Cyber MacGeddon 2025-09-05 16:21:06 +01:00
parent efca43c95b
commit ba44ef7b52

View file

@ -244,9 +244,12 @@ Bob Johnson,bob@company.org,42,UK"""
# Validation Tests # Validation Tests
def test_validation_rules_required_fields(self): def test_validation_rules_required_fields(self):
"""Test validation rules for required fields""" """Test CLI processes data with validation requirements"""
record = {"name": "John", "email": ""} # Missing required email test_data = "name,email\nJohn,\nJane,jane@email.com"
mappings = [ descriptor_with_validation = {
"version": "1.0",
"format": {"type": "csv", "encoding": "utf-8", "options": {"header": True}},
"mappings": [
{ {
"source_field": "name", "source_field": "name",
"target_field": "name", "target_field": "name",
@ -259,10 +262,28 @@ Bob Johnson,bob@company.org,42,UK"""
"transforms": [], "transforms": [],
"validation": [{"type": "required"}] "validation": [{"type": "required"}]
} }
] ],
"output": {
"format": "trustgraph-objects",
"schema_name": "customer",
"options": {"confidence": 0.9, "batch_size": 100}
}
}
result = apply_transformations(record, mappings) input_file = self.create_temp_file(test_data, '.csv')
descriptor_file = self.create_temp_file(json.dumps(descriptor_with_validation), '.json')
# Should still process but may log warnings try:
assert "name" in result # Should process despite validation issues (warnings logged)
assert "email" in result result = load_structured_data(
api_url="http://localhost:8088",
input_file=input_file,
descriptor_file=descriptor_file,
dry_run=True
)
assert result is None # Dry run returns None
finally:
self.cleanup_temp_file(input_file)
self.cleanup_temp_file(descriptor_file)