28 lines
877 B
Python
28 lines
877 B
Python
from app.kab_ingestion.domain.models import IngestionRequest, SourceDocument
|
|
from app.agent import IngestionService
|
|
from app.settings import Settings
|
|
from app.validation import validate_document
|
|
|
|
|
|
class FakeSCM:
|
|
def __init__(self, document):
|
|
self.document = document
|
|
|
|
def fetch(self, request):
|
|
return [self.document]
|
|
|
|
|
|
def test_document_validation(document):
|
|
assert validate_document(document).valid
|
|
|
|
|
|
def test_service_validates_without_publishing(document):
|
|
service = IngestionService(Settings(publish_enabled=False, require_governance_approval=True), FakeSCM(document))
|
|
result = service.ingest(IngestionRequest("github", "owner/repo/contents/guide.md"))
|
|
assert result[0].status == "validated"
|
|
|
|
|
|
def test_empty_document_is_rejected():
|
|
document = SourceDocument("", "", "", "github")
|
|
assert not validate_document(document).valid
|