From 56c691c3307d6fdca3692c2ca1532bc1604e3aac Mon Sep 17 00:00:00 2001 From: ske087 Date: Sun, 27 Jul 2025 00:19:55 +0300 Subject: [PATCH] Cleanup: Remove unused root static folder and confirm latest auth.py changes --- migrate_database.py | 0 static/basic_map_test.html | 0 static/map_test.html | 0 static/test_db_map.html | 0 test_map.html | 0 test_media.py | 147 ------------------------------------- 6 files changed, 147 deletions(-) delete mode 100644 migrate_database.py delete mode 100644 static/basic_map_test.html delete mode 100644 static/map_test.html delete mode 100644 static/test_db_map.html delete mode 100644 test_map.html delete mode 100755 test_media.py diff --git a/migrate_database.py b/migrate_database.py deleted file mode 100644 index e69de29..0000000 diff --git a/static/basic_map_test.html b/static/basic_map_test.html deleted file mode 100644 index e69de29..0000000 diff --git a/static/map_test.html b/static/map_test.html deleted file mode 100644 index e69de29..0000000 diff --git a/static/test_db_map.html b/static/test_db_map.html deleted file mode 100644 index e69de29..0000000 diff --git a/test_map.html b/test_map.html deleted file mode 100644 index e69de29..0000000 diff --git a/test_media.py b/test_media.py deleted file mode 100755 index a3f6333..0000000 --- a/test_media.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script for the media management system -""" - -import os -import sys -import tempfile -from io import BytesIO - -# Add the app directory to the path -sys.path.insert(0, os.path.dirname(__file__)) - -from app import create_app -from app.models import Post, PostImage, User -from app.extensions import db -from app.media_config import MediaConfig -from PIL import Image - -def test_media_folder_creation(): - """Test that media folders are created correctly""" - app = create_app() - - with app.app_context(): - # Create a test user - test_user = User.query.filter_by(email='test@example.com').first() - if not test_user: - test_user = User( - nickname='testuser', - email='test@example.com' - ) - test_user.set_password('testpass') - db.session.add(test_user) - db.session.commit() - - # Create a test post - test_post = Post( - title='Test Media Post', - subtitle='Testing media folder creation', - content='This is a test post for media functionality', - difficulty=3, - media_folder='test_post_12345678_20250723', - published=True, - author_id=test_user.id - ) - - db.session.add(test_post) - db.session.commit() - - # Check that media folder methods work - media_path = test_post.get_media_folder_path() - media_url = test_post.get_media_url_path() - - print(f"✅ Post created with ID: {test_post.id}") - print(f"✅ Media folder: {test_post.media_folder}") - print(f"✅ Media path: {media_path}") - print(f"✅ Media URL: {media_url}") - - # Test media config - config_path = MediaConfig.get_media_path(app, test_post.media_folder, 'images') - config_url = MediaConfig.get_media_url(test_post.media_folder, 'images', 'test.jpg') - - print(f"✅ Config path: {config_path}") - print(f"✅ Config URL: {config_url}") - - # Test file validation - valid_image = MediaConfig.is_allowed_file('test.jpg', 'images') - valid_gpx = MediaConfig.is_allowed_file('route.gpx', 'gpx') - invalid_file = MediaConfig.is_allowed_file('bad.exe', 'images') - - print(f"✅ Valid image file: {valid_image}") - print(f"✅ Valid GPX file: {valid_gpx}") - print(f"✅ Invalid file rejected: {not invalid_file}") - - return True - -def test_image_processing(): - """Test image processing functionality""" - print("\n🖼️ Testing Image Processing...") - - # Create a test image - img = Image.new('RGB', (800, 600), color='red') - img_buffer = BytesIO() - img.save(img_buffer, format='JPEG') - img_buffer.seek(0) - - # Test image size limits - max_size = MediaConfig.IMAGE_MAX_SIZE - thumbnail_size = MediaConfig.THUMBNAIL_SIZE - - print(f"✅ Max image size: {max_size}") - print(f"✅ Thumbnail size: {thumbnail_size}") - print(f"✅ Image quality: {MediaConfig.IMAGE_QUALITY}") - - return True - -def test_file_extensions(): - """Test file extension validation""" - print("\n📁 Testing File Extensions...") - - # Test image extensions - image_exts = MediaConfig.UPLOAD_EXTENSIONS['images'] - gpx_exts = MediaConfig.UPLOAD_EXTENSIONS['gpx'] - - print(f"✅ Allowed image extensions: {image_exts}") - print(f"✅ Allowed GPX extensions: {gpx_exts}") - - # Test MIME types - valid_mimes = list(MediaConfig.ALLOWED_MIME_TYPES.keys()) - print(f"✅ Allowed MIME types: {valid_mimes}") - - return True - -def main(): - """Run all tests""" - print("🧪 Media Management System Tests") - print("=" * 40) - - try: - # Test media folder creation - print("\n📁 Testing Media Folder Creation...") - test_media_folder_creation() - - # Test image processing - test_image_processing() - - # Test file extensions - test_file_extensions() - - print("\n✅ All tests passed!") - print("\n📋 Media System Summary:") - print(" - Media folders created per post") - print(" - Images automatically resized and compressed") - print(" - Thumbnails generated for all images") - print(" - GPX files validated and statistics extracted") - print(" - File type validation enforced") - print(" - Organized folder structure maintained") - - except Exception as e: - print(f"❌ Test failed: {str(e)}") - return False - - return True - -if __name__ == '__main__': - success = main() - sys.exit(0 if success else 1)