mdify-cli 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mdify_cli-2.0.0/mdify_cli.egg-info → mdify_cli-2.1.0}/PKG-INFO +1 -1
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify/__init__.py +1 -1
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify/cli.py +9 -3
- {mdify_cli-2.0.0 → mdify_cli-2.1.0/mdify_cli.egg-info}/PKG-INFO +1 -1
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/pyproject.toml +1 -1
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/tests/test_cli.py +48 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/LICENSE +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/README.md +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/assets/mdify.png +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify/__main__.py +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify/container.py +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify/docling_client.py +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify_cli.egg-info/SOURCES.txt +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify_cli.egg-info/dependency_links.txt +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify_cli.egg-info/entry_points.txt +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify_cli.egg-info/requires.txt +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/mdify_cli.egg-info/top_level.txt +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/setup.cfg +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/tests/test_container.py +0 -0
- {mdify_cli-2.0.0 → mdify_cli-2.1.0}/tests/test_docling_client.py +0 -0
|
@@ -571,9 +571,15 @@ def main() -> int:
|
|
|
571
571
|
print(f"Run with --pull=missing or pull manually: {preferred} pull {image}")
|
|
572
572
|
return 1
|
|
573
573
|
|
|
574
|
-
# Resolve paths
|
|
575
|
-
|
|
576
|
-
|
|
574
|
+
# Resolve paths (use absolute() as fallback if resolve() fails due to permissions)
|
|
575
|
+
try:
|
|
576
|
+
input_path = Path(args.input).resolve()
|
|
577
|
+
except PermissionError:
|
|
578
|
+
input_path = Path(args.input).absolute()
|
|
579
|
+
try:
|
|
580
|
+
output_dir = Path(args.out_dir).resolve()
|
|
581
|
+
except PermissionError:
|
|
582
|
+
output_dir = Path(args.out_dir).absolute()
|
|
577
583
|
|
|
578
584
|
# Validate input
|
|
579
585
|
if not input_path.exists():
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Tests for mdify CLI runtime detection."""
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from unittest.mock import patch, Mock
|
|
5
6
|
import pytest
|
|
6
7
|
|
|
@@ -135,3 +136,50 @@ class TestNewCLIArgs:
|
|
|
135
136
|
with patch.object(sys, "argv", ["mdify", "--port", "65535", "test.pdf"]):
|
|
136
137
|
args = parse_args()
|
|
137
138
|
assert args.port == 65535
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class TestPathResolution:
|
|
142
|
+
"""Tests for path resolution error handling."""
|
|
143
|
+
|
|
144
|
+
def test_input_path_permission_error_fallback(self, tmp_path):
|
|
145
|
+
"""Test that PermissionError on resolve() falls back to absolute()."""
|
|
146
|
+
test_file = tmp_path / "test.pdf"
|
|
147
|
+
test_file.write_bytes(b"%PDF-1.4 test")
|
|
148
|
+
|
|
149
|
+
original_resolve = Path.resolve
|
|
150
|
+
|
|
151
|
+
def mock_resolve(self, strict=False):
|
|
152
|
+
if "test.pdf" in str(self):
|
|
153
|
+
raise PermissionError("Operation not permitted")
|
|
154
|
+
return original_resolve(self, strict=strict)
|
|
155
|
+
|
|
156
|
+
with patch.object(Path, "resolve", mock_resolve):
|
|
157
|
+
with patch.object(sys, "argv", ["mdify", str(test_file)]):
|
|
158
|
+
with patch("mdify.cli.detect_runtime", return_value=None):
|
|
159
|
+
from mdify.cli import main
|
|
160
|
+
|
|
161
|
+
result = main()
|
|
162
|
+
assert result == 1
|
|
163
|
+
|
|
164
|
+
def test_output_path_permission_error_fallback(self, tmp_path):
|
|
165
|
+
"""Test that PermissionError on output path resolve() falls back to absolute()."""
|
|
166
|
+
test_file = tmp_path / "test.pdf"
|
|
167
|
+
test_file.write_bytes(b"%PDF-1.4 test")
|
|
168
|
+
output_dir = tmp_path / "output"
|
|
169
|
+
|
|
170
|
+
original_resolve = Path.resolve
|
|
171
|
+
|
|
172
|
+
def mock_resolve(self, strict=False):
|
|
173
|
+
if "output" in str(self):
|
|
174
|
+
raise PermissionError("Operation not permitted")
|
|
175
|
+
return original_resolve(self, strict=strict)
|
|
176
|
+
|
|
177
|
+
with patch.object(Path, "resolve", mock_resolve):
|
|
178
|
+
with patch.object(
|
|
179
|
+
sys, "argv", ["mdify", str(test_file), "-o", str(output_dir)]
|
|
180
|
+
):
|
|
181
|
+
with patch("mdify.cli.detect_runtime", return_value=None):
|
|
182
|
+
from mdify.cli import main
|
|
183
|
+
|
|
184
|
+
result = main()
|
|
185
|
+
assert result == 1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|