LifeRPG_v2.0/modern/tests/test_export_import.py
TLimoges33 7fe4ae5365
🧙‍♂️ Transform LifeRPG into The Wizard's Grimoire - Production-Ready Application
 Major Features Added:
- Complete magical theming and rebranding from LifeRPG to The Wizard's Grimoire
- Production-grade React frontend with Tailwind CSS v4 and magical aesthetics
- Comprehensive analytics dashboard with Recharts integration (ScryingPortal)
- Push notifications system with PWA service worker support
- Drag & drop functionality using @dnd-kit for habit reordering
- Social features with friends system and leaderboards
- Performance optimization tools and monitoring
- Mobile app enhancement with PWA installation support

🏗️ Technical Infrastructure:
- Advanced service worker with offline support and background sync
- Zustand state management for scalable application state
- Production-ready UI component system with enhanced Button, Card, Input
- Progressive Web App (PWA) with manifest and app installation
- FastAPI backend with comprehensive API endpoints
- Docker containerization and CI/CD pipeline setup

📱 Progressive Web App Features:
- Offline functionality with intelligent caching
- Push notification support for habit reminders
- App installation on mobile and desktop platforms
- Background sync for offline data management
- Performance monitoring and optimization tools

🎨 User Experience:
- Magical wizard/grimoire theming throughout application
- Responsive design optimized for all device sizes
- Drag & drop habit management with smooth animations
- Interactive analytics with multiple chart types
- Social connectivity with friends and competitive features
- Comprehensive notification and performance settings

🔧 Developer Experience:
- Modern development stack with Vite and React
- Comprehensive testing setup and CI/CD pipelines
- Code quality tools with pre-commit hooks
- Docker development environment
- Detailed documentation and implementation guides

This represents a complete transformation from prototype to production-ready application with enterprise-grade features and magical user experience.
2025-08-30 17:32:42 +00:00

49 lines
1.3 KiB
Python

import os
import json
import importlib
from modern.backend import models
def test_export_import_roundtrip(client):
# Login as admin
r = client.post('/api/v1/auth/login', json={'email': 'admin@test', 'password': 'pass'})
assert r.status_code == 200
# Create some data directly in DB
db = models.SessionLocal()
try:
u = models.User(email='u@test')
db.add(u)
db.flush()
p = models.Project(user_id=u.id, title='P1')
db.add(p)
db.flush()
h = models.Habit(user_id=u.id, project_id=p.id, title='H1')
db.add(h)
db.commit()
finally:
db.close()
# Export
exp = client.get('/api/v1/admin/export')
assert exp.status_code == 200
ciphertext = exp.json().get('ciphertext')
assert ciphertext
# Drop and recreate schema
import modern.backend.models as m
importlib.reload(m)
m.Base.metadata.drop_all(bind=m.engine)
m.Base.metadata.create_all(bind=m.engine)
# Import
imp = client.post('/api/v1/admin/import', json={'ciphertext': ciphertext})
assert imp.status_code == 200
# Verify user restored
db2 = models.SessionLocal()
try:
assert db2.query(models.User).filter_by(email='u@test').first() is not None
finally:
db2.close()