[Test] Add unit coverage for content-based file type detection

クローズ 初心者向け
#15 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@srivarshni7 がすでに取り組んでいます。

2026年11月2日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, security
領域
testing

調査の方向性

utilities/file_types.py にある 4 つのヘルパー、sniff_magic、detect_type_key、type_label、guess_kind から始めてください。既存のテストの書き方は tests/test_file_type_icons.py で確認し、その後 Qt に依存しない新しいテストモジュールを追加してください。PNG または PDF のマジックバイトが矛盾する拡張子より優先されること、.tar.gz が正しく解決されること、不明なバイナリが安全なカテゴリにフォールバックすること、そして QApplication なしでテストが通ることを満たせば完了です。

索引モデルが issue の本文から書いたものです。

説明

good first issue test

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.gz are 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分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ANCORATE/EncryptHome のほかの issue

ANCORATE/EncryptHome の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。