Merge pull request #158 from christianlouis/copilot/remove-duplicate-utils-and-license-routes
refactor: remove duplicate utils.py and dead license_routes
This commit is contained in:
+3
-2
@@ -30,8 +30,9 @@ This document tracks test coverage improvements for DocuElevate. The goal is to
|
|||||||
- Test skipping when URL not configured
|
- Test skipping when URL not configured
|
||||||
- Test error handling for failed requests
|
- Test error handling for failed requests
|
||||||
|
|
||||||
- [x] `app/utils.py` (0% → Still 0%) ⚠️
|
- [x] `app/utils/` package (exports via __init__.py) ✅
|
||||||
- Simple re-export module, coverage is from actual usage
|
- Package exports tested in test_reexports.py
|
||||||
|
- Individual module coverage from actual usage
|
||||||
|
|
||||||
- [x] `app/frontend.py` (0% → 100%) ✅
|
- [x] `app/frontend.py` (0% → 100%) ✅
|
||||||
- Simple re-export module, test imports work
|
- Simple re-export module, test imports work
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from fastapi import APIRouter, HTTPException
|
|
||||||
from fastapi.responses import PlainTextResponse
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/licenses/lgpl.txt", response_class=PlainTextResponse)
|
|
||||||
async def get_lgpl_license():
|
|
||||||
"""
|
|
||||||
Serve the LGPL license text file
|
|
||||||
"""
|
|
||||||
license_path = Path("frontend/static/licenses/lgpl.txt")
|
|
||||||
if not license_path.exists():
|
|
||||||
raise HTTPException(status_code=404, detail="License file not found")
|
|
||||||
|
|
||||||
with open(license_path, "r") as f:
|
|
||||||
return f.read()
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# app/utils.py
|
|
||||||
# This file is deprecated. Functions have been moved to the utils package.
|
|
||||||
# To avoid breaking existing imports, we'll import and re-export the functions
|
|
||||||
from app.utils.file_operations import hash_file # noqa: F401
|
|
||||||
from app.utils.logging import log_task_progress # noqa: F401
|
|
||||||
|
|
||||||
# These functions are now available directly from the app.utils package
|
|
||||||
-64
@@ -1,64 +0,0 @@
|
|||||||
[tool:pytest]
|
|
||||||
# Pytest configuration
|
|
||||||
testpaths = tests
|
|
||||||
python_files = test_*.py
|
|
||||||
python_classes = Test*
|
|
||||||
python_functions = test_*
|
|
||||||
|
|
||||||
# Output options
|
|
||||||
addopts =
|
|
||||||
--verbose
|
|
||||||
--strict-markers
|
|
||||||
--strict-config
|
|
||||||
--cov=app
|
|
||||||
--cov-report=term-missing
|
|
||||||
--cov-report=html
|
|
||||||
--cov-report=xml
|
|
||||||
--cov-branch
|
|
||||||
--cov-fail-under=0
|
|
||||||
# Note: Coverage threshold set to 0 initially, should be increased gradually
|
|
||||||
# Target: 80% coverage for production code
|
|
||||||
|
|
||||||
# Markers for organizing tests
|
|
||||||
markers =
|
|
||||||
unit: Unit tests for individual functions/methods
|
|
||||||
integration: Integration tests for API endpoints and workflows
|
|
||||||
slow: Tests that take significant time to run
|
|
||||||
security: Security-related tests
|
|
||||||
requires_external: Tests requiring external services (OpenAI, Azure, etc.)
|
|
||||||
requires_db: Tests requiring database
|
|
||||||
requires_redis: Tests requiring Redis
|
|
||||||
|
|
||||||
# Ignore patterns
|
|
||||||
norecursedirs =
|
|
||||||
.git
|
|
||||||
.tox
|
|
||||||
dist
|
|
||||||
build
|
|
||||||
*.egg
|
|
||||||
__pycache__
|
|
||||||
.venv
|
|
||||||
venv
|
|
||||||
env
|
|
||||||
|
|
||||||
# Coverage options
|
|
||||||
[coverage:run]
|
|
||||||
source = app
|
|
||||||
omit =
|
|
||||||
*/tests/*
|
|
||||||
*/test_*.py
|
|
||||||
*/__pycache__/*
|
|
||||||
*/venv/*
|
|
||||||
*/env/*
|
|
||||||
*/.venv/*
|
|
||||||
|
|
||||||
[coverage:report]
|
|
||||||
exclude_lines =
|
|
||||||
pragma: no cover
|
|
||||||
def __repr__
|
|
||||||
raise AssertionError
|
|
||||||
raise NotImplementedError
|
|
||||||
if __name__ == .__main__.:
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
@abstractmethod
|
|
||||||
@abc.abstractmethod
|
|
||||||
@@ -5,7 +5,7 @@ from unittest.mock import patch, MagicMock
|
|||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
class TestUtilsCompat:
|
class TestUtilsCompat:
|
||||||
"""Tests for app/utils.py backward compatibility module."""
|
"""Tests for app.utils package exports."""
|
||||||
|
|
||||||
def test_imports_hash_file(self):
|
def test_imports_hash_file(self):
|
||||||
"""Test that hash_file can be imported from utils."""
|
"""Test that hash_file can be imported from utils."""
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
Tests for simple re-export modules (app/utils.py, app/frontend.py, app/utils/config_validator.py)
|
Tests for simple re-export modules (app/frontend.py, app/utils/config_validator.py)
|
||||||
|
|
||||||
These modules are simple re-exports of functions from other modules.
|
These modules are simple re-exports of functions from other modules.
|
||||||
We test that imports work correctly.
|
We test that imports work correctly, including the app.utils package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -10,7 +10,7 @@ import pytest
|
|||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
class TestUtilsReexports:
|
class TestUtilsReexports:
|
||||||
"""Test that app/utils.py re-exports work correctly"""
|
"""Test that app.utils package exports work correctly"""
|
||||||
|
|
||||||
def test_hash_file_import(self):
|
def test_hash_file_import(self):
|
||||||
"""Test that hash_file can be imported from app.utils"""
|
"""Test that hash_file can be imported from app.utils"""
|
||||||
@@ -26,12 +26,12 @@ class TestUtilsReexports:
|
|||||||
# Function should exist and be callable
|
# Function should exist and be callable
|
||||||
assert callable(log_task_progress)
|
assert callable(log_task_progress)
|
||||||
|
|
||||||
def test_utils_module_is_backward_compatible(self):
|
def test_utils_package_exports(self):
|
||||||
"""Test that utils module maintains backward compatibility"""
|
"""Test that utils package exports expected functions"""
|
||||||
# The module comment says it's deprecated but maintains compatibility
|
# The utils package should export functions via __init__.py
|
||||||
import app.utils
|
import app.utils
|
||||||
|
|
||||||
# Module should exist and have expected attributes
|
# Package should exist and have expected attributes
|
||||||
assert hasattr(app.utils, "hash_file")
|
assert hasattr(app.utils, "hash_file")
|
||||||
assert hasattr(app.utils, "log_task_progress")
|
assert hasattr(app.utils, "log_task_progress")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user