thechaiexperiment commited on
Commit
abbe7db
·
verified ·
1 Parent(s): 044467a

Delete tests

Browse files
Files changed (1) hide show
  1. tests/test_document_service.py +0 -67
tests/test_document_service.py DELETED
@@ -1,67 +0,0 @@
1
- import pytest
2
- from fastapi import UploadFile
3
- from io import BytesIO
4
- from services.document_service import document_service
5
- import os
6
-
7
- @pytest.fixture
8
- def sample_pdf():
9
- return BytesIO(b"%PDF-1.4\n%Test PDF content")
10
-
11
- @pytest.fixture
12
- def sample_docx():
13
- return BytesIO(b"PK\x03\x04\x14\x00\x00\x00\x08\x00")
14
-
15
- @pytest.fixture
16
- def sample_image():
17
- return BytesIO(b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR")
18
-
19
- @pytest.mark.asyncio
20
- async def test_save_upload_file(sample_pdf):
21
- file = UploadFile(
22
- filename="test.pdf",
23
- file=sample_pdf
24
- )
25
- file_path = await document_service.save_upload_file(file)
26
- assert file_path.endswith("test.pdf")
27
- assert os.path.exists(file_path)
28
-
29
- @pytest.mark.asyncio
30
- async def test_process_pdf(sample_pdf):
31
- file = UploadFile(
32
- filename="test.pdf",
33
- file=sample_pdf
34
- )
35
- file_path = await document_service.save_upload_file(file)
36
- result = await document_service.process_document(file_path)
37
- assert "text" in result
38
- assert result["type"] == "pdf"
39
-
40
- @pytest.mark.asyncio
41
- async def test_process_docx(sample_docx):
42
- file = UploadFile(
43
- filename="test.docx",
44
- file=sample_docx
45
- )
46
- file_path = await document_service.save_upload_file(file)
47
- result = await document_service.process_document(file_path)
48
- assert "text" in result
49
- assert result["type"] == "word"
50
-
51
- @pytest.mark.asyncio
52
- async def test_process_image(sample_image):
53
- file = UploadFile(
54
- filename="test.png",
55
- file=sample_image
56
- )
57
- file_path = await document_service.save_upload_file(file)
58
- result = await document_service.process_document(file_path)
59
- assert "text" in result
60
- assert result["type"] == "image"
61
-
62
- @pytest.mark.asyncio
63
- async def test_segment_document():
64
- text = "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
65
- segments = await document_service.segment_document(text, max_segment_size=20)
66
- assert len(segments) > 0
67
- assert all(len(segment) <= 20 for segment in segments)