File size: 1,687 Bytes
03c0888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio
from pathlib import Path
from crawl4ai.docs_manager import DocsManager
from click.testing import CliRunner
from crawl4ai.cli import cli

def test_cli():
    """Test all CLI commands"""
    runner = CliRunner()
    
    print("\n1. Testing docs update...")
    # Use sync version for testing
    docs_manager = DocsManager()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(docs_manager.fetch_docs())

    # print("\n2. Testing listing...")
    # result = runner.invoke(cli, ['docs', 'list'])
    # print(f"Status: {'βœ…' if result.exit_code == 0 else '❌'}")
    # print(result.output)

    # print("\n2. Testing index building...")
    # result = runner.invoke(cli, ['docs', 'index'])
    # print(f"Status: {'βœ…' if result.exit_code == 0 else '❌'}")
    # print(f"Output: {result.output}")

    # print("\n3. Testing search...")
    # result = runner.invoke(cli, ['docs', 'search', 'how to use crawler', '--build-index'])
    # print(f"Status: {'βœ…' if result.exit_code == 0 else '❌'}")
    # print(f"First 200 chars: {result.output[:200]}...")    
    
    # print("\n4. Testing combine with sections...")
    # result = runner.invoke(cli, ['docs', 'combine', 'chunking_strategies', 'extraction_strategies', '--mode', 'extended'])
    # print(f"Status: {'βœ…' if result.exit_code == 0 else '❌'}")
    # print(f"First 200 chars: {result.output[:200]}...")

    print("\n5. Testing combine all sections...")
    result = runner.invoke(cli, ['docs', 'combine', '--mode', 'condensed'])
    print(f"Status: {'βœ…' if result.exit_code == 0 else '❌'}")
    print(f"First 200 chars: {result.output[:200]}...")

if __name__ == "__main__":
    test_cli()