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

Đã đóng Phù hợp với người mới
#15 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@srivarshni7 đang làm issue này rồi.

Từ ngày 2/11/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, security
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu với bốn hàm hỗ trợ trong utilities/file_types.py: sniff_magic, detect_type_key, type_label và guess_kind. Xem tests/test_file_type_icons.py để nắm kiểu viết test hiện có, rồi thêm một module test mới không phụ thuộc Qt. Hoàn thành khi magic bytes của PNG hoặc PDF được ưu tiên hơn phần mở rộng tệp mâu thuẫn, .tar.gz được nhận diện đúng, tệp nhị phân không rõ được đưa về nhóm an toàn và các test chạy được mà không cần QApplication.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
1
Fork
5
Merge trung bình
4 giờ 22 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ANCORATE/EncryptHome

Tất cả issue của ANCORATE/EncryptHome

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.