Skip to content

Latest commit

Β 

History

History
124 lines (94 loc) Β· 2.34 KB

File metadata and controls

124 lines (94 loc) Β· 2.34 KB

Testing Quick Start

πŸš€ Run All Tests

cd ~/torrent-downloader
python3 run_tests.py

Expected Result:

Status: βœ“ ALL TESTS PASSED
Tests run:    96
  βœ“ Passed:   96
Time: 1.77s

πŸ“‹ Test Suite Overview

File Tests What It Tests
tests/test_utils.py 32 Utility functions (formatting, sanitization)
tests/test_validation.py 29 Input validation & security
tests/test_single_instance.py 8 IPC communication
tests/test_torrent_core.py 14 Libtorrent integration
tests/test_remove_torrents.py 13 Remove/delete functionality
Total 96 All functionality

🎯 Common Commands

# Run all tests
python3 run_tests.py

# Run specific test file
python3 run_tests.py --suite test_utils
python3 run_tests.py --suite test_validation
python3 run_tests.py --suite test_single_instance
python3 run_tests.py --suite test_torrent_core

# List all tests
python3 run_tests.py --list

# Quiet mode (minimal output)
python3 run_tests.py --quiet

# Verbose mode
python3 run_tests.py --verbose

βœ… What's Tested

βœ“ Utility Functions

  • Size formatting (B, KiB, MiB, GiB, TiB, PiB)
  • Speed formatting
  • Time formatting
  • Filename sanitization
  • Magnet link validation

βœ“ Security

  • Path traversal prevention
  • Command injection prevention
  • Script injection prevention
  • SQL injection prevention
  • Null byte handling

βœ“ Input Validation

  • Bandwidth limits
  • Magnet links (format, hash, length)
  • File paths
  • Filenames

βœ“ Torrent Core

  • Session creation
  • Magnet parsing
  • Resume data
  • Info hash extraction
  • Bencode/bdecode

βœ“ Single Instance

  • Socket creation/cleanup
  • IPC communication
  • Instance detection
  • Multiple clients

πŸ”§ Adding New Tests

  1. Create/edit test file in tests/ directory
  2. Run tests: python3 run_tests.py
  3. Tests are auto-discovered!

Example:

# tests/test_my_feature.py
import unittest

class TestMyFeature(unittest.TestCase):
    def test_something(self):
        self.assertTrue(True)

πŸ“– Full Documentation

See TEST_SUITE_GUIDE.md for complete documentation including:

  • Detailed test descriptions
  • CI/CD integration
  • Best practices
  • Troubleshooting

Status: βœ… 96/96 tests passing Coverage: 98% Runtime: ~1.8 seconds