Files
wehub-resource-sync fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:28:29 +08:00

40 lines
1.4 KiB
Python

import pytest
from application.vectorstore.document_class import Document
@pytest.mark.unit
class TestDocument:
def test_create_document(self):
doc = Document(page_content="hello world", metadata={"source": "test"})
assert doc.page_content == "hello world"
assert doc.metadata == {"source": "test"}
def test_document_is_string(self):
doc = Document(page_content="hello world", metadata={})
assert isinstance(doc, str)
assert str(doc) == "hello world"
def test_document_string_equality(self):
doc = Document(page_content="hello", metadata={"k": "v"})
assert doc == "hello"
def test_document_empty_metadata(self):
doc = Document(page_content="text", metadata={})
assert doc.metadata == {}
def test_document_empty_content(self):
doc = Document(page_content="", metadata={"a": 1})
assert doc.page_content == ""
assert doc == ""
def test_document_preserves_complex_metadata(self):
meta = {"source": "file.txt", "page": 3, "nested": {"key": "val"}}
doc = Document(page_content="content", metadata=meta)
assert doc.metadata["nested"]["key"] == "val"
def test_document_string_operations(self):
doc = Document(page_content="hello world", metadata={})
assert doc.upper() == "HELLO WORLD"
assert doc.split() == ["hello", "world"]
assert "world" in doc