mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 00:16:20 +00:00
refactor: rename the application package to docsgpt
The backend import package is now docsgpt, the name it will carry on PyPI; application was far too generic to install into anyone's site-packages. git mv plus a mechanical rewrite of every import, dotted string and path reference: 734 Python files, the compose files, Dockerfile, workflows, docs, setup scripts, devcontainer, k8s manifests, vscode config, pytest and coverage config, .gitignore. Behaviour is unchanged. Kept for one release: - A top-level application package whose meta-path finder resolves application.x.y to the already-imported docsgpt.x.y object, so old imports and entry points (celery -A application.app.celery, uvicorn application.asgi:asgi_app) keep working with a FutureWarning. - Celery registers every application.* task name as an alias of its docsgpt.* task on start-up, so messages queued by the previous release still run. The redbeat key prefix moves to redbeat:docsgpt:v2: so schedule entries the previous release wrote are left unread instead of firing twice. The backend image builds from the repository root (docker build -f docsgpt/Dockerfile .) so it can ship the alias package; a root .dockerignore allow-lists docsgpt/ and application/ and keeps caches, local data, .env files, the sample index files and the Dockerfile out. Compose and the image workflows point at the new context.
This commit is contained in:
1 parent
3e7f1f91b4
commit
574f96341e
984 files changed
+9847
-9682
No files matched your search
@@ -1,4 +1,4 @@
|
||||
"""Comprehensive tests for application/parser/file/docs_parser.py
|
||||
"""Comprehensive tests for docsgpt/parser/file/docs_parser.py
|
||||
|
||||
Covers: PDFParser (init, parse with pypdf, parse as image, import error),
|
||||
DocxParser (init, parse, import error).
|
||||
@@ -9,7 +9,7 @@ from unittest.mock import MagicMock, patch, mock_open
|
||||
|
||||
import pytest
|
||||
|
||||
from application.parser.file.docs_parser import PDFParser, DocxParser
|
||||
from docsgpt.parser.file.docs_parser import PDFParser, DocxParser
|
||||
|
||||
|
||||
# =====================================================================
|
||||
@@ -44,7 +44,7 @@ class TestPDFParserInit:
|
||||
@pytest.mark.unit
|
||||
class TestPDFParserParse:
|
||||
|
||||
@patch("application.parser.file.docs_parser.settings")
|
||||
@patch("docsgpt.parser.file.docs_parser.settings")
|
||||
def test_parse_with_pypdf(self, mock_settings):
|
||||
mock_settings.PARSE_PDF_AS_IMAGE = False
|
||||
|
||||
@@ -58,7 +58,7 @@ class TestPDFParserParse:
|
||||
mock_reader = MagicMock()
|
||||
mock_reader.pages = [mock_page1, mock_page2]
|
||||
|
||||
with patch("application.parser.file.docs_parser.PdfReader",
|
||||
with patch("docsgpt.parser.file.docs_parser.PdfReader",
|
||||
create=True), \
|
||||
patch("builtins.open", mock_open()):
|
||||
# Need to patch the import inside the function
|
||||
@@ -74,8 +74,8 @@ class TestPDFParserParse:
|
||||
finally:
|
||||
del sys.modules["pypdf"]
|
||||
|
||||
@patch("application.parser.file.docs_parser.settings")
|
||||
@patch("application.parser.file.docs_parser.requests")
|
||||
@patch("docsgpt.parser.file.docs_parser.settings")
|
||||
@patch("docsgpt.parser.file.docs_parser.requests")
|
||||
def test_parse_as_image(self, mock_requests, mock_settings):
|
||||
mock_settings.PARSE_PDF_AS_IMAGE = True
|
||||
|
||||
@@ -89,7 +89,7 @@ class TestPDFParserParse:
|
||||
result = parser.parse_file(Path("test.pdf"))
|
||||
assert result == "# OCR Result"
|
||||
|
||||
@patch("application.parser.file.docs_parser.settings")
|
||||
@patch("docsgpt.parser.file.docs_parser.settings")
|
||||
def test_parse_raises_on_missing_pypdf(self, mock_settings):
|
||||
mock_settings.PARSE_PDF_AS_IMAGE = False
|
||||
|
||||
@@ -196,17 +196,17 @@ class TestBaseParserProperties:
|
||||
class TestDocsParserGaps:
|
||||
def test_pdf_parser_parse_as_image(self, tmp_path):
|
||||
"""Cover lines 33-34: PARSE_PDF_AS_IMAGE sends to external service."""
|
||||
from application.parser.file.docs_parser import PDFParser
|
||||
from docsgpt.parser.file.docs_parser import PDFParser
|
||||
|
||||
pdf_file = tmp_path / "test.pdf"
|
||||
pdf_file.write_bytes(b"%PDF-1.4 fake content")
|
||||
|
||||
with patch(
|
||||
"application.parser.file.docs_parser.settings"
|
||||
"docsgpt.parser.file.docs_parser.settings"
|
||||
) as mock_settings:
|
||||
mock_settings.PARSE_PDF_AS_IMAGE = True
|
||||
with patch(
|
||||
"application.parser.file.docs_parser.requests.post"
|
||||
"docsgpt.parser.file.docs_parser.requests.post"
|
||||
) as mock_post:
|
||||
mock_post.return_value = MagicMock(
|
||||
json=MagicMock(return_value={"markdown": "# Parsed Content"})
|
||||
@@ -218,7 +218,7 @@ class TestDocsParserGaps:
|
||||
|
||||
def test_docx_parser_init_parser(self):
|
||||
"""Cover line 59: DocxParser._init_parser returns empty dict."""
|
||||
from application.parser.file.docs_parser import DocxParser
|
||||
from docsgpt.parser.file.docs_parser import DocxParser
|
||||
|
||||
parser = DocxParser()
|
||||
config = parser._init_parser()
|
||||
@@ -226,7 +226,7 @@ class TestDocsParserGaps:
|
||||
|
||||
def test_docx_parser_import_error(self):
|
||||
"""Cover line 63: ImportError when docx2txt not installed."""
|
||||
from application.parser.file.docs_parser import DocxParser
|
||||
from docsgpt.parser.file.docs_parser import DocxParser
|
||||
|
||||
parser = DocxParser()
|
||||
with patch.dict("sys.modules", {"docx2txt": None}):
|
||||
|
||||
Reference in new issue
Block a user