-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_patch_improvements.py
More file actions
60 lines (48 loc) · 1.56 KB
/
Copy pathtest_patch_improvements.py
File metadata and controls
60 lines (48 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# backend/src/core/tests/test_patch_improvements.py
import sys
from src.core.file_system_manager import FileSystemManager
import tempfile
import os
def test_fuzzy_patch():
"""Test the new fuzzy patch functionality"""
# Create test file
with tempfile.TemporaryDirectory() as temp_dir:
fsm = FileSystemManager(temp_dir)
# Create a test Django settings file
settings_content = '''
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
]
'''
fsm.write_file('settings.py', settings_content)
# Test patch that would normally fail (wrong line numbers)
bad_patch = """--- a/settings.py
+++ b/settings.py
@@ -10,6 +10,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+'calculator',
]
MIDDLEWARE = ["""
try:
fsm.apply_patch('settings.py', bad_patch)
print("✅ Fuzzy patch succeeded!")
# Verify result
result = fsm.read_file('settings.py')
if "'calculator'," in result:
print("✅ Calculator app was added correctly!")
else:
print("❌ Calculator app not found in result")
except Exception as e:
print(f"❌ Patch failed: {e}")
if __name__ == "__main__":
test_fuzzy_patch()