mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 06:57:17 -05:00
feat: scaffold BlackRoad OS Phase 2 infrastructure
Implements complete Phase 2 scaffold across 6 core modules: ## New Modules ### 1. Backend API Enhancements - Add system router with /version, /config/public, /os/state endpoints - Register system router in main.py - Add comprehensive tests for system endpoints ### 2. Core OS Runtime (core_os/) - Implement UserSession, Window, OSState models - Add state management functions (open_window, close_window, etc.) - Create Backend API adapter for communication - Include full test suite for models and state ### 3. Operator Engine (operator_engine/) - Build job registry with example jobs - Implement simple scheduler with lifecycle management - Optional HTTP server on port 8001 - Complete tests for jobs and scheduler ### 4. Web Client Enhancements - Add CoreOSClient JavaScript class - Integrate system API endpoints - Event-driven architecture for state updates - Zero dependencies, vanilla JavaScript ### 5. Prism Console (prism-console/) - Modern dark-themed admin UI - Multi-tab navigation (Overview, Jobs, Agents, Logs, System) - Real-time metrics dashboard - Backend API integration with auto-refresh ### 6. Documentation (codex-docs/) - Complete MkDocs-based documentation - Architecture guides and component docs - Infrastructure setup guides - API reference documentation ## CI/CD - Add core-os-tests.yml workflow - Add operator-tests.yml workflow - Add docs-build.yml workflow ## Documentation - Create BLACKROAD_OS_REPO_MAP.md cross-reference - Add README for each module - Comprehensive integration documentation ## Summary - 37 new files created - ~3,500 lines of new code - 5 test suites with 15+ tests - 3 new CI workflows - 10+ documentation pages All modules are minimal working skeletons ready for integration. Designed to be extracted into separate repos if needed. Phase 2 scaffold complete and ready for review.
This commit is contained in:
95
core_os/tests/test_state.py
Normal file
95
core_os/tests/test_state.py
Normal file
@@ -0,0 +1,95 @@
|
||||
"""Tests for OS state management"""
|
||||
import pytest
|
||||
from core_os.state import (
|
||||
get_initial_state,
|
||||
get_current_state,
|
||||
open_window,
|
||||
close_window,
|
||||
minimize_window,
|
||||
maximize_window,
|
||||
set_active_window,
|
||||
reset_state,
|
||||
)
|
||||
from core_os.models import WindowState
|
||||
|
||||
|
||||
def test_get_initial_state():
|
||||
"""Test getting initial OS state"""
|
||||
reset_state() # Reset to clean state
|
||||
state = get_initial_state()
|
||||
|
||||
assert state is not None
|
||||
assert state.session is not None
|
||||
assert len(state.desktop_items) > 0
|
||||
assert len(state.taskbar_items) > 0
|
||||
|
||||
|
||||
def test_open_window():
|
||||
"""Test opening a new window"""
|
||||
reset_state()
|
||||
initial_count = len(get_current_state().windows)
|
||||
|
||||
state = open_window("notepad", "Notepad")
|
||||
|
||||
assert len(state.windows) == initial_count + 1
|
||||
assert state.windows[-1].app_id == "notepad"
|
||||
assert state.windows[-1].title == "Notepad"
|
||||
assert state.active_window_id == state.windows[-1].id
|
||||
|
||||
|
||||
def test_close_window():
|
||||
"""Test closing a window"""
|
||||
reset_state()
|
||||
|
||||
# Open a window first
|
||||
state = open_window("test-app")
|
||||
window_id = state.windows[0].id
|
||||
initial_count = len(state.windows)
|
||||
|
||||
# Close it
|
||||
state = close_window(window_id)
|
||||
|
||||
assert len(state.windows) == initial_count - 1
|
||||
|
||||
|
||||
def test_minimize_window():
|
||||
"""Test minimizing a window"""
|
||||
reset_state()
|
||||
|
||||
# Open and minimize
|
||||
state = open_window("test-app")
|
||||
window_id = state.windows[0].id
|
||||
|
||||
state = minimize_window(window_id)
|
||||
|
||||
assert state.windows[0].state == WindowState.MINIMIZED
|
||||
|
||||
|
||||
def test_maximize_window():
|
||||
"""Test maximizing a window"""
|
||||
reset_state()
|
||||
|
||||
# Open and maximize
|
||||
state = open_window("test-app")
|
||||
window_id = state.windows[0].id
|
||||
|
||||
state = maximize_window(window_id)
|
||||
|
||||
assert state.windows[0].state == WindowState.MAXIMIZED
|
||||
|
||||
|
||||
def test_set_active_window():
|
||||
"""Test setting active window"""
|
||||
reset_state()
|
||||
|
||||
# Open two windows
|
||||
open_window("app1")
|
||||
open_window("app2")
|
||||
|
||||
state = get_current_state()
|
||||
first_window_id = state.windows[0].id
|
||||
|
||||
# Set first window as active
|
||||
state = set_active_window(first_window_id)
|
||||
|
||||
assert state.active_window_id == first_window_id
|
||||
Reference in New Issue
Block a user