forked from username/flaskpaste
add CLI enhancements and scheduled cleanup
CLI commands: - list: show user's pastes with pagination - search: filter by type (glob), after/before timestamps - update: modify content, password, or extend expiry - export: save pastes to directory with optional decryption API changes: - PUT /<id>: update paste content and metadata - GET /pastes: add type, after, before query params Scheduled tasks: - Thread-safe cleanup with per-task intervals - Activate cleanup_expired_hashes (15min) - Activate cleanup_rate_limits (5min) Tests: 205 passing
This commit is contained in:
@@ -2,14 +2,37 @@
|
||||
|
||||
import pytest
|
||||
|
||||
import app.database as db_module
|
||||
from app import create_app
|
||||
from app.api.routes import reset_rate_limits
|
||||
|
||||
|
||||
def _clear_database():
|
||||
"""Clear all data from database tables for test isolation."""
|
||||
if db_module._memory_db_holder is not None:
|
||||
db_module._memory_db_holder.execute("DELETE FROM pastes")
|
||||
db_module._memory_db_holder.execute("DELETE FROM content_hashes")
|
||||
db_module._memory_db_holder.execute("DELETE FROM issued_certificates")
|
||||
db_module._memory_db_holder.execute("DELETE FROM certificate_authority")
|
||||
db_module._memory_db_holder.commit()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
"""Create application for testing."""
|
||||
app = create_app("testing")
|
||||
yield app
|
||||
# Reset global state for test isolation
|
||||
reset_rate_limits()
|
||||
_clear_database()
|
||||
|
||||
test_app = create_app("testing")
|
||||
|
||||
# Clear database again after app init (in case init added anything)
|
||||
_clear_database()
|
||||
|
||||
yield test_app
|
||||
|
||||
# Cleanup after test
|
||||
reset_rate_limits()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user