[Test] Add unit coverage for content-based file type detection
维护者通常 1 天内回复
@srivarshni7 已经在做这个了。
开始于 2026年11月2日。
评估
调研方向
从 utilities/file_types.py 中的四个辅助函数开始:sniff_magic、detect_type_key、type_label 和 guess_kind。参考 tests/test_file_type_icons.py 了解现有的测试风格,然后添加一个不依赖 Qt 的新测试模块。完成的标准是:PNG 或 PDF 的魔数字节优先于冲突的扩展名,.tar.gz 能被正确解析,未知二进制文件回退到安全类别,并且测试在没有 QApplication 的情况下通过。
由索引模型根据 Issue 内容生成。
描述
Summary
utilities/file_types.py contains content sniffing and compound-extension handling, but the test suite currently has no focused tests for these helpers. Regressions could affect file labels and preview selection without being detected.
Proposed solution
Add a small, Qt-independent test module covering sniff_magic, detect_type_key, type_label, and guess_kind. Use representative byte samples and filenames to verify magic bytes take precedence over extensions, .tar.gz is handled correctly, text and unknown data are classified safely, and case-insensitive extensions work.
Acceptance criteria
- Tests cover at least PNG/PDF or another representative magic-byte pair.
- A content type overrides a conflicting filename extension.
- Compound extensions such as
.tar.gzare covered. - Unknown binary data falls back to the expected safe category.
- Tests run without creating a Qt application.
Security considerations
Tests must use synthetic data only and must not weaken or bypass encryption behavior.
Additional context
Relevant file: utilities/file_types.py; existing UI icon tests are in tests/test_file_type_icons.py.
- 主要语言
- Python
- 星标
- 1
- 派生
- 5
- 平均合并
- 4 小时 22 分钟
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ANCORATE/EncryptHome 的其他 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 76/100
ANCORATE/EncryptHome#24 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 65/100
ANCORATE/EncryptHome#17 ·
维护者通常 1 天内回复
-
good first issue ux
难度 2/5 1-3 小时 新手友好度 65/100
ANCORATE/EncryptHome#10 ·
维护者通常 1 天内回复
查看 ANCORATE/EncryptHome 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
igormcsouza/tether#278 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
aws-samples/sample-per-model-bedrock#803 ·
维护者通常 1 天内回复
-
documentation p1
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/accelerate#4511 ·
维护者通常 1 天内回复
-
follow-up
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复