132 lines
3.9 KiB
Python
132 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple test runner for GUI integration - no pytest required.
|
|
Run: python tests/test_gui_simple.py
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project to path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
def test_project_data_fields():
|
|
"""Test ProjectData has fields GUI uses."""
|
|
from core.project_manager import ProjectData
|
|
|
|
project = ProjectData(
|
|
id=1,
|
|
name="Test Project",
|
|
type="hunt",
|
|
status="active"
|
|
)
|
|
|
|
# Required fields
|
|
assert hasattr(project, 'id'), "Missing: id"
|
|
assert hasattr(project, 'name'), "Missing: name"
|
|
assert hasattr(project, 'type'), "Missing: type"
|
|
assert hasattr(project, 'status'), "Missing: status"
|
|
|
|
# These fields caused AttributeErrors
|
|
assert not hasattr(project, 'session_count'), "Unexpected: session_count"
|
|
assert not hasattr(project, 'description'), "Unexpected: description"
|
|
|
|
print("✅ ProjectData fields correct")
|
|
return True
|
|
|
|
def test_project_manager_methods():
|
|
"""Test ProjectManager has methods GUI calls."""
|
|
from core.project_manager import ProjectManager
|
|
|
|
pm = ProjectManager()
|
|
|
|
# Required methods
|
|
assert hasattr(pm, 'list_projects'), "Missing: list_projects"
|
|
assert hasattr(pm, 'load_project'), "Missing: load_project"
|
|
assert hasattr(pm, 'create_project'), "Missing: create_project"
|
|
assert hasattr(pm, 'start_session'), "Missing: start_session"
|
|
assert hasattr(pm, 'end_session'), "Missing: end_session"
|
|
assert hasattr(pm, 'record_loot'), "Missing: record_loot"
|
|
|
|
# These were wrong method names
|
|
assert not hasattr(pm, 'get_all_projects'), "Should not have: get_all_projects"
|
|
assert not hasattr(pm, 'get_project'), "Should not have: get_project"
|
|
|
|
print("✅ ProjectManager methods correct")
|
|
return True
|
|
|
|
def test_create_project_signature():
|
|
"""Test create_project has correct signature."""
|
|
from core.project_manager import ProjectManager
|
|
import inspect
|
|
|
|
sig = inspect.signature(ProjectManager.create_project)
|
|
params = list(sig.parameters.keys())
|
|
|
|
# Correct signature: create_project(name, project_type, metadata=None)
|
|
assert 'name' in params, "Missing: name"
|
|
assert 'project_type' in params, "Missing: project_type"
|
|
assert 'metadata' in params, "Missing: metadata"
|
|
|
|
print("✅ create_project signature correct")
|
|
return True
|
|
|
|
def test_list_projects_signature():
|
|
"""Test list_projects returns list."""
|
|
from core.project_manager import ProjectManager
|
|
|
|
pm = ProjectManager()
|
|
projects = pm.list_projects()
|
|
|
|
assert isinstance(projects, list), "list_projects should return list"
|
|
|
|
print(f"✅ list_projects works (found {len(projects)} projects)")
|
|
return True
|
|
|
|
def test_log_watcher_methods():
|
|
"""Test LogWatcher has required methods."""
|
|
from core.log_watcher import LogWatcher
|
|
|
|
assert hasattr(LogWatcher, 'subscribe'), "Missing: subscribe"
|
|
assert hasattr(LogWatcher, 'start'), "Missing: start"
|
|
assert hasattr(LogWatcher, 'stop'), "Missing: stop"
|
|
|
|
print("✅ LogWatcher methods correct")
|
|
return True
|
|
|
|
def run_all_tests():
|
|
"""Run all tests."""
|
|
print("="*60)
|
|
print("GUI INTEGRATION TESTS")
|
|
print("="*60)
|
|
print()
|
|
|
|
tests = [
|
|
test_project_data_fields,
|
|
test_project_manager_methods,
|
|
test_create_project_signature,
|
|
test_list_projects_signature,
|
|
test_log_watcher_methods,
|
|
]
|
|
|
|
passed = 0
|
|
failed = 0
|
|
|
|
for test in tests:
|
|
try:
|
|
if test():
|
|
passed += 1
|
|
except Exception as e:
|
|
print(f"❌ {test.__name__} FAILED: {e}")
|
|
failed += 1
|
|
|
|
print()
|
|
print("="*60)
|
|
print(f"RESULTS: {passed} passed, {failed} failed")
|
|
print("="*60)
|
|
|
|
return failed == 0
|
|
|
|
if __name__ == "__main__":
|
|
success = run_all_tests()
|
|
sys.exit(0 if success else 1) |