mirror of
https://github.com/Dasemu/x-space-downloader.git
synced 2026-10-13 21:49:45 +00:00
feat: add CLI main module with Click integration
Implemented the CLI entry point using Click framework. The CLI: - Accepts Space URL as an argument - Supports --cookies and --output options - Validates URLs using the validator module - Downloads Spaces using the downloader module - Provides clear success and error messages - Uses proper exit codes (0=success, 1=validation error, 2=download error) Test uses Click's CliRunner to test CLI without running actual downloads. Mocks validate_space_url and download_space functions for isolated testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
21
tests/test_main.py
Normal file
21
tests/test_main.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
from unittest.mock import patch, Mock
|
||||
from src.main import cli
|
||||
|
||||
|
||||
def test_cli_valid_url(tmp_path):
|
||||
"""Test CLI with valid URL."""
|
||||
runner = CliRunner()
|
||||
|
||||
with patch('src.main.validate_space_url') as mock_validate, \
|
||||
patch('src.main.download_space') as mock_download:
|
||||
|
||||
mock_validate.return_value = (True, "1ZkKzZWnVRRKv", None)
|
||||
mock_download.return_value = str(tmp_path / "space_1ZkKzZWnVRRKv.mp3")
|
||||
|
||||
result = runner.invoke(cli, ['https://x.com/i/spaces/1ZkKzZWnVRRKv'])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "Successfully downloaded" in result.output
|
||||
assert "space_1ZkKzZWnVRRKv.mp3" in result.output
|
||||
Reference in New Issue
Block a user