الميزات: إضافة أدوات جديدة لمعالجة ملفات PDF، تشمل التلخيص والترجمة واستخراج الجداول.
- تفعيل مكون SummarizePdf لإنشاء ملخصات PDF باستخدام الذكاء الاصطناعي. - تفعيل مكون TranslatePdf لترجمة محتوى PDF إلى لغات متعددة. - تفعيل مكون TableExtractor لاستخراج الجداول من ملفات PDF. - تحديث الصفحة الرئيسية والتوجيه ليشمل الأدوات الجديدة. - إضافة ترجمات للأدوات الجديدة باللغات الإنجليزية والعربية والفرنسية. - توسيع أنواع واجهة برمجة التطبيقات (API) لدعم الميزات الجديدة المتعلقة بمعالجة ملفات PDF. --feat: Initialize frontend with React, Vite, and Tailwind CSS - Set up main entry point for React application. - Create About, Home, NotFound, Privacy, and Terms pages with SEO support. - Implement API service for file uploads and task management. - Add global styles using Tailwind CSS. - Create utility functions for SEO and text processing. - Configure Vite for development and production builds. - Set up Nginx configuration for serving frontend and backend. - Add scripts for cleanup of expired files and sitemap generation. - Implement deployment script for production environment.
This commit is contained in:
43
backend/tests/test_html_to_pdf.py
Normal file
43
backend/tests/test_html_to_pdf.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Tests for HTML to PDF endpoint — POST /api/convert/html-to-pdf."""
|
||||
import io
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
class TestHtmlToPdf:
|
||||
def test_no_file(self, client):
|
||||
"""Should return 400 when no file provided."""
|
||||
response = client.post('/api/convert/html-to-pdf')
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_success(self, client, monkeypatch):
|
||||
"""Should return 202 with task_id on valid HTML upload."""
|
||||
mock_task = MagicMock()
|
||||
mock_task.id = 'html-pdf-task-id'
|
||||
monkeypatch.setattr(
|
||||
'app.routes.html_to_pdf.validate_actor_file',
|
||||
lambda f, allowed_types, actor: ('test.html', 'html'),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
'app.routes.html_to_pdf.generate_safe_path',
|
||||
lambda ext, folder_type: ('html-pdf-task-id', '/tmp/mock.html'),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
'app.routes.html_to_pdf.html_to_pdf_task.delay',
|
||||
MagicMock(return_value=mock_task),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
'werkzeug.datastructures.file_storage.FileStorage.save',
|
||||
lambda self, dst, buffer_size=16384: None,
|
||||
)
|
||||
|
||||
data = {
|
||||
'file': (io.BytesIO(b'<html><body>Hello</body></html>'), 'test.html'),
|
||||
}
|
||||
response = client.post(
|
||||
'/api/convert/html-to-pdf',
|
||||
data=data,
|
||||
content_type='multipart/form-data',
|
||||
)
|
||||
assert response.status_code == 202
|
||||
json_data = response.get_json()
|
||||
assert 'task_id' in json_data
|
||||
Reference in New Issue
Block a user