- Added comprehensive API documentation for NFO endpoints - Section 6 in API.md with all 8 endpoints documented - Updated task5_status.md to reflect 100% completion - Marked Task 5 complete in instructions.md - All 17 tests passing (1 skipped by design) - Endpoints: check, create, update, content, media status, download, batch, missing
96 lines
3.4 KiB
Python
96 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Remove patch contexts from NFO test file."""
|
|
|
|
with open('tests/api/test_nfo_endpoints.py', 'r') as f:
|
|
lines = f.readlines()
|
|
|
|
new_lines = []
|
|
i = 0
|
|
skip_until_indent = None
|
|
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
|
|
# Check if we're starting a patch context for dependencies (not settings)
|
|
if 'with patch(' in line and ('get_series_app' in line or 'get_nfo_service' in line):
|
|
# Skip this line and continuation lines until we find the closing '):'
|
|
indent = len(line) - len(line.lstrip())
|
|
i += 1
|
|
|
|
# Skip continuation lines
|
|
while i < len(lines):
|
|
current = lines[i]
|
|
# Check if it's a continuation
|
|
if (current.strip().startswith('patch(') or
|
|
current.strip().startswith('), patch(') or
|
|
current.strip().startswith('return_value=') or
|
|
(current.strip() == '):' and not lines[i-1].strip().startswith('mock_settings'))):
|
|
i += 1
|
|
if current.strip() == '):':
|
|
break
|
|
else:
|
|
break
|
|
|
|
# If next line is blank, skip it too
|
|
if i < len(lines) and not lines[i].strip():
|
|
i += 1
|
|
|
|
# Keep settings patches but remove dependency patches from them
|
|
elif 'with patch(' in line and 'settings' in line:
|
|
# This is a settings patch - keep it but might need to simplify
|
|
# Check if it's multi-line with dependency patches
|
|
if '\\' in line: # Multi-line patch
|
|
# Keep the settings patch line
|
|
new_lines.append(line)
|
|
i += 1
|
|
|
|
# Skip dependency patches in the multi-line context
|
|
while i < len(lines):
|
|
current = lines[i]
|
|
if ('get_series_app' in current or 'get_nfo_service' in current or
|
|
'patch(' in current):
|
|
i += 1
|
|
if current.strip() == '):':
|
|
# Found end of patch context, adjust indentation
|
|
i += 1
|
|
break
|
|
else:
|
|
# Not a patch continuation, this is actual code
|
|
break
|
|
|
|
# Dedent the code that was inside patch context by 4 spaces
|
|
while i < len(lines):
|
|
current = lines[i]
|
|
current_indent = len(current) - len(current.lstrip())
|
|
|
|
# Blank line
|
|
if not current.strip():
|
|
new_lines.append(current)
|
|
i += 1
|
|
continue
|
|
|
|
# If we hit a new test or class, we're done
|
|
if (current.strip().startswith('def test_') or
|
|
current.strip().startswith('class ') or
|
|
current.strip().startswith('@pytest')):
|
|
break
|
|
|
|
# Dedent by 4 if indented
|
|
if current_indent >= 12:
|
|
new_lines.append(' ' * (current_indent - 4) + current.lstrip())
|
|
else:
|
|
new_lines.append(current)
|
|
i += 1
|
|
else:
|
|
# Single line settings patch - should not happen but keep it
|
|
new_lines.append(line)
|
|
i += 1
|
|
else:
|
|
new_lines.append(line)
|
|
i += 1
|
|
|
|
with open('tests/api/test_nfo_endpoints.py', 'w') as f:
|
|
f.writelines(new_lines)
|
|
|
|
print("Cleaned up patch contexts")
|