feat: enhance menu theming with comprehensive documentation and testing support
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# TheChart Scripts Directory
|
||||
|
||||
This directory contains testing and utility scripts for TheChart application.
|
||||
This directory contains interactive demonstrations and utility scripts for TheChart application.
|
||||
|
||||
## Scripts Overview
|
||||
|
||||
@@ -36,15 +36,62 @@ Tests entry update functionality.
|
||||
- Validates data modification operations
|
||||
- Tests date validation and duplicate handling
|
||||
|
||||
## Usage
|
||||
#### `test_keyboard_shortcuts.py`
|
||||
Tests keyboard shortcut functionality.
|
||||
- Validates keyboard event handling
|
||||
- Tests shortcut combinations and responses
|
||||
|
||||
All scripts should be run from the project root directory:
|
||||
### Interactive Demonstrations
|
||||
|
||||
#### `test_menu_theming.py`
|
||||
Interactive demonstration of menu theming functionality.
|
||||
- Live theme switching demonstration
|
||||
- Visual display of theme colors
|
||||
- Real-time menu color updates
|
||||
|
||||
```bash
|
||||
cd /home/will/Code/thechart
|
||||
.venv/bin/python scripts/<script_name>.py
|
||||
.venv/bin/python scripts/test_menu_theming.py
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
All scripts should be run from the project root directory using the virtual environment:
|
||||
|
||||
```bash
|
||||
cd /home/will/Code/thechart
|
||||
source .venv/bin/activate.fish # For fish shell
|
||||
# OR
|
||||
source .venv/bin/activate # For bash/zsh
|
||||
|
||||
python scripts/<script_name>.py
|
||||
```
|
||||
|
||||
## Test Organization
|
||||
|
||||
### Unit Tests
|
||||
Located in `/tests/` directory:
|
||||
- `test_theme_manager.py` - Theme manager functionality tests
|
||||
- `test_data_manager.py` - Data management tests
|
||||
- `test_ui_manager.py` - UI component tests
|
||||
- `test_graph_manager.py` - Graph functionality tests
|
||||
- And more...
|
||||
|
||||
Run unit tests with:
|
||||
```bash
|
||||
cd /home/will/Code/thechart
|
||||
.venv/bin/python -m pytest tests/
|
||||
```
|
||||
|
||||
### Integration Tests
|
||||
Located in `/scripts/` directory:
|
||||
- `integration_test.py` - Export system integration test
|
||||
- Feature-specific test scripts
|
||||
|
||||
### Interactive Demos
|
||||
Located in `/scripts/` directory:
|
||||
- `test_menu_theming.py` - Menu theming demonstration
|
||||
|
||||
## Test Data
|
||||
|
||||
- Integration tests create temporary export files in `integration_test_exports/` (auto-cleaned)
|
||||
@@ -59,3 +106,5 @@ When adding new scripts:
|
||||
3. Add proper docstrings and error handling
|
||||
4. Update this README with script documentation
|
||||
5. Follow the project's linting and formatting standards
|
||||
6. For unit tests, place them in `/tests/` directory
|
||||
7. For integration tests or demos, place them in `/scripts/` directory
|
||||
|
||||
153
scripts/test_menu_theming.py
Normal file
153
scripts/test_menu_theming.py
Normal file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Interactive demonstration of menu theming functionality."""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tkinter as tk
|
||||
|
||||
# Add the src directory to the path so we can import the modules
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../src"))
|
||||
|
||||
from theme_manager import ThemeManager
|
||||
|
||||
|
||||
def demo_menu_theming():
|
||||
"""Interactive demonstration of menu theming with different themes."""
|
||||
|
||||
# Set up logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
print("Menu Theming Interactive Demo")
|
||||
print("=============================")
|
||||
|
||||
# Create root window
|
||||
root = tk.Tk()
|
||||
root.title("Menu Theming Demo - TheChart")
|
||||
root.geometry("500x400")
|
||||
|
||||
# Initialize theme manager
|
||||
theme_manager = ThemeManager(root, logger)
|
||||
|
||||
# Create demo menubar using the new convenience method
|
||||
menubar = theme_manager.create_themed_menu(root)
|
||||
root.config(menu=menubar)
|
||||
|
||||
# Create submenus
|
||||
file_menu = theme_manager.create_themed_menu(menubar, tearoff=0)
|
||||
theme_menu = theme_manager.create_themed_menu(menubar, tearoff=0)
|
||||
help_menu = theme_manager.create_themed_menu(menubar, tearoff=0)
|
||||
|
||||
menubar.add_cascade(label="File", menu=file_menu)
|
||||
menubar.add_cascade(label="Theme", menu=theme_menu)
|
||||
menubar.add_cascade(label="Help", menu=help_menu)
|
||||
|
||||
# Populate file menu
|
||||
file_menu.add_command(label="Demo Item 1")
|
||||
file_menu.add_command(label="Demo Item 2")
|
||||
file_menu.add_separator()
|
||||
file_menu.add_command(label="Exit Demo", command=root.quit)
|
||||
|
||||
# Populate help menu
|
||||
help_menu.add_command(
|
||||
label="About Demo",
|
||||
command=lambda: tk.messagebox.showinfo(
|
||||
"About", "Interactive menu theming demonstration for TheChart"
|
||||
),
|
||||
)
|
||||
|
||||
# Theme information display
|
||||
theme_info_frame = tk.Frame(root, relief="ridge", bd=2)
|
||||
theme_info_frame.pack(fill="x", padx=20, pady=10)
|
||||
|
||||
current_theme_label = tk.Label(
|
||||
theme_info_frame,
|
||||
text=f"Current Theme: {theme_manager.get_current_theme().title()}",
|
||||
font=("Arial", 12, "bold"),
|
||||
)
|
||||
current_theme_label.pack(pady=5)
|
||||
|
||||
colors_display = tk.Text(theme_info_frame, height=6, wrap="word")
|
||||
colors_display.pack(fill="x", padx=10, pady=5)
|
||||
|
||||
def update_theme_display():
|
||||
"""Update the theme information display."""
|
||||
current_theme_label.config(
|
||||
text=f"Current Theme: {theme_manager.get_current_theme().title()}"
|
||||
)
|
||||
|
||||
menu_colors = theme_manager.get_menu_colors()
|
||||
colors_text = "Current Menu Colors:\n"
|
||||
for key, value in menu_colors.items():
|
||||
colors_text += f" {key}: {value}\n"
|
||||
|
||||
colors_display.delete(1.0, tk.END)
|
||||
colors_display.insert(1.0, colors_text)
|
||||
|
||||
# Function to apply theme and update displays
|
||||
def apply_theme_and_update(theme_name):
|
||||
"""Apply theme and update all displays."""
|
||||
print(f"Switching to theme: {theme_name}")
|
||||
if theme_manager.apply_theme(theme_name):
|
||||
# Re-theme all menus
|
||||
theme_manager.configure_menu(menubar)
|
||||
theme_manager.configure_menu(file_menu)
|
||||
theme_manager.configure_menu(theme_menu)
|
||||
theme_manager.configure_menu(help_menu)
|
||||
|
||||
# Update display
|
||||
update_theme_display()
|
||||
print(f" ✓ Successfully applied {theme_name} theme")
|
||||
else:
|
||||
print(f" ✗ Failed to apply {theme_name} theme")
|
||||
|
||||
# Create theme selection menu
|
||||
available_themes = theme_manager.get_available_themes()
|
||||
current_theme = theme_manager.get_current_theme()
|
||||
|
||||
for theme in available_themes:
|
||||
theme_menu.add_radiobutton(
|
||||
label=theme.title(),
|
||||
command=lambda t=theme: apply_theme_and_update(t),
|
||||
value=theme == current_theme,
|
||||
)
|
||||
|
||||
# Instructions
|
||||
instructions_frame = tk.Frame(root)
|
||||
instructions_frame.pack(fill="both", expand=True, padx=20, pady=10)
|
||||
|
||||
tk.Label(
|
||||
instructions_frame,
|
||||
text="Menu Theming Demonstration",
|
||||
font=("Arial", 16, "bold"),
|
||||
).pack(pady=10)
|
||||
|
||||
instructions_text = """
|
||||
Instructions:
|
||||
1. Use the Theme menu to switch between different themes
|
||||
2. Observe how menu colors change to match each theme
|
||||
3. Try the File and Help menus to see the color effects
|
||||
4. Menu backgrounds, text, and hover effects all update automatically
|
||||
|
||||
Available themes: """ + ", ".join([t.title() for t in available_themes])
|
||||
|
||||
tk.Label(
|
||||
instructions_frame,
|
||||
text=instructions_text,
|
||||
justify="left",
|
||||
wraplength=450,
|
||||
).pack(pady=10)
|
||||
|
||||
# Initialize display
|
||||
update_theme_display()
|
||||
|
||||
print(f"Demo window opened with {len(available_themes)} available themes.")
|
||||
print("Try the Theme menu to see different color schemes!")
|
||||
|
||||
# Show the window
|
||||
root.mainloop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo_menu_theming()
|
||||
160
scripts/verify_testing.py
Normal file
160
scripts/verify_testing.py
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick verification script for consolidated testing structure."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run_command(cmd, description):
|
||||
"""Run a command and return the result."""
|
||||
print(f"\n🔍 {description}")
|
||||
print(f"Command: {cmd}")
|
||||
print("-" * 50)
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
shell=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
cwd="/home/will/Code/thechart",
|
||||
)
|
||||
if result.returncode == 0:
|
||||
print("✅ SUCCESS")
|
||||
if result.stdout:
|
||||
print(result.stdout[:500]) # First 500 chars
|
||||
else:
|
||||
print("❌ FAILED")
|
||||
if result.stderr:
|
||||
print(result.stderr[:500])
|
||||
return result.returncode == 0
|
||||
except Exception as e:
|
||||
print(f"❌ ERROR: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def verify_test_structure():
|
||||
"""Verify the consolidated test structure."""
|
||||
print("🧪 TheChart Testing Structure Verification")
|
||||
print("=" * 50)
|
||||
|
||||
# Check if we're in the right directory
|
||||
if not os.path.exists("src/main.py"):
|
||||
print("❌ Please run this script from the project root directory")
|
||||
return False
|
||||
|
||||
# Check test directories exist
|
||||
test_dirs = ["tests", "scripts"]
|
||||
for dir_name in test_dirs:
|
||||
if os.path.exists(dir_name):
|
||||
print(f"✅ Directory {dir_name}/ exists")
|
||||
else:
|
||||
print(f"❌ Directory {dir_name}/ missing")
|
||||
return False
|
||||
|
||||
# Check key test files exist
|
||||
test_files = [
|
||||
"tests/test_theme_manager.py",
|
||||
"scripts/test_menu_theming.py",
|
||||
"scripts/integration_test.py",
|
||||
"docs/TESTING.md",
|
||||
]
|
||||
|
||||
for file_path in test_files:
|
||||
if os.path.exists(file_path):
|
||||
print(f"✅ File {file_path} exists")
|
||||
else:
|
||||
print(f"❌ File {file_path} missing")
|
||||
return False
|
||||
|
||||
# Check virtual environment
|
||||
if os.path.exists(".venv/bin/python"):
|
||||
print("✅ Virtual environment found")
|
||||
else:
|
||||
print("❌ Virtual environment not found")
|
||||
return False
|
||||
|
||||
print("\n📋 Test Structure Summary:")
|
||||
print("Unit Tests: tests/")
|
||||
print("Integration Tests: scripts/")
|
||||
print("Interactive Demos: scripts/")
|
||||
print("Documentation: docs/TESTING.md")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def run_test_verification():
|
||||
"""Run basic test verification."""
|
||||
print("\n🚀 Running Test Verification")
|
||||
print("=" * 50)
|
||||
|
||||
success_count = 0
|
||||
total_tests = 0
|
||||
|
||||
# Test 1: Unit test syntax check
|
||||
total_tests += 1
|
||||
if run_command(
|
||||
"source .venv/bin/activate.fish && "
|
||||
"python -m py_compile tests/test_theme_manager.py",
|
||||
"Unit test syntax check",
|
||||
):
|
||||
success_count += 1
|
||||
|
||||
# Test 2: Integration test syntax check
|
||||
total_tests += 1
|
||||
if run_command(
|
||||
"source .venv/bin/activate.fish && "
|
||||
"python -m py_compile scripts/integration_test.py",
|
||||
"Integration test syntax check",
|
||||
):
|
||||
success_count += 1
|
||||
|
||||
# Test 3: Demo script syntax check
|
||||
total_tests += 1
|
||||
if run_command(
|
||||
"source .venv/bin/activate.fish && "
|
||||
"python -m py_compile scripts/test_menu_theming.py",
|
||||
"Demo script syntax check",
|
||||
):
|
||||
success_count += 1
|
||||
|
||||
# Test 4: Check if pytest is available
|
||||
total_tests += 1
|
||||
pytest_cmd = (
|
||||
"source .venv/bin/activate.fish && "
|
||||
"python -c 'import pytest; print(f\"pytest version: {pytest.__version__}\")'"
|
||||
)
|
||||
if run_command(pytest_cmd, "Pytest availability check"):
|
||||
success_count += 1
|
||||
|
||||
print(f"\n📊 Test Verification Results: {success_count}/{total_tests} passed")
|
||||
|
||||
if success_count == total_tests:
|
||||
print("✅ All verification tests passed!")
|
||||
print("\n🎯 Next Steps:")
|
||||
print("1. Run unit tests: python -m pytest tests/ -v")
|
||||
print("2. Run integration test: python scripts/integration_test.py")
|
||||
print("3. Try interactive demo: python scripts/test_menu_theming.py")
|
||||
else:
|
||||
print("❌ Some verification tests failed. Check the output above.")
|
||||
|
||||
return success_count == total_tests
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🧪 TheChart Consolidated Testing Verification")
|
||||
print("=" * 60)
|
||||
|
||||
# Verify structure
|
||||
if not verify_test_structure():
|
||||
print("\n❌ Test structure verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
# Run verification tests
|
||||
if not run_test_verification():
|
||||
print("\n❌ Test verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
print("\n🎉 All verification checks passed!")
|
||||
print("📚 See docs/TESTING.md for complete testing guide")
|
||||
Reference in New Issue
Block a user