Commit 2acb8f4
committed
test: improve extract.py coverage and address async safety issues
Coverage improvements:
- Add tests for image download with None URLs (lines 124-136)
- Add tests for directory handling scenarios (lines 420-454)
- Test deletion when final_dir exists
- Test renaming when rename_existing_folders=True
- Test using existing directory when renaming disabled
- Simplify download_ad tests to focus on observable behavior
- Improve type annotations (tmp_path: Path instead of Any)
- Coverage increased to 87.70%
Async safety improvements:
- Remove unused # noqa: ASYNC240 from _exists, _isdir, ainput
- Eliminate TOCTOU race in directory creation using mkdir(exist_ok=True)
- Offload dicts.save_dict to executor (blocking I/O)
Path handling improvements:
- Migrate to pathlib.Path for OS-agnostic file operations
- Replace string concatenation with Path operations
- Use Path.name instead of rsplit for filename extraction
Exception handling improvements:
- Narrow exception handling in _download_and_save_image_sync
- Catch only expected errors (URLError, HTTPError, OSError, shutil.Error)
- Don't swallow programming errors
Translation updates:
- Update German translation for directory creation message1 parent aafde54 commit 2acb8f4
File tree
4 files changed
+210
-195
lines changed- src/kleinanzeigen_bot
- resources
- tests/unit
4 files changed
+210
-195
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
940 | | - | |
| 940 | + | |
941 | 941 | | |
942 | 942 | | |
943 | 943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
82 | 81 | | |
83 | | - | |
| 82 | + | |
84 | 83 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
145 | | - | |
| 147 | + | |
| 148 | + | |
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
0 commit comments