import pytest
from src.project_manager import (
 save_context_preset,
 load_context_preset,
 delete_context_preset
)

def test_save_context_preset():
 project_dict = {}
 preset_name = "test_preset"
 files = ["file1.py", "file2.py"]
 screenshots = ["screenshot1.png"]
 
 save_context_preset(project_dict, preset_name, files, screenshots)
 
 assert "context_presets" in project_dict
 assert preset_name in project_dict["context_presets"]
 assert project_dict["context_presets"][preset_name]["files"] == files
 assert project_dict["context_presets"][preset_name]["screenshots"] == screenshots

def test_load_context_preset():
 project_dict = {
  "context_presets": {
   "test_preset": {
    "files": ["file1.py"],
    "screenshots": ["screenshot1.png"]
   }
  }
 }
 
 preset = load_context_preset(project_dict, "test_preset")
 
 assert preset["files"] == ["file1.py"]
 assert preset["screenshots"] == ["screenshot1.png"]

def test_load_nonexistent_preset():
 project_dict = {"context_presets": {}}
 with pytest.raises(KeyError):
  load_context_preset(project_dict, "nonexistent")

def test_delete_context_preset():
 project_dict = {
  "context_presets": {
   "test_preset": {
    "files": ["file1.py"],
    "screenshots": []
   }
  }
 }
 
 delete_context_preset(project_dict, "test_preset")
 
 assert "test_preset" not in project_dict["context_presets"]

def test_delete_nonexistent_preset_no_error():
 project_dict = {"context_presets": {}}
 # Should not raise error if it doesn't exist
 delete_context_preset(project_dict, "nonexistent")
 assert "nonexistent" not in project_dict["context_presets"]
