Skip to content

Commit 6ff8b89

Browse files
Checkpoint before follow-up message
Co-authored-by: nicoragne <nicoragne@hotmail.fr>
1 parent 9231552 commit 6ff8b89

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

test_gitpython_integration.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Simple test script to verify GitPython integration works.
4+
"""
5+
6+
import asyncio
7+
import sys
8+
from pathlib import Path
9+
10+
# Add specific path for git_utils module
11+
git_utils_path = Path(__file__).parent / "src" / "gitingest" / "utils"
12+
sys.path.insert(0, str(git_utils_path))
13+
14+
# Import the specific functions we need to test
15+
import git_utils
16+
17+
18+
async def test_basic_functions():
19+
"""Test basic functionality without external dependencies."""
20+
print("🔍 Testing GitPython integration...")
21+
22+
# Test 1: Test token validation (no external deps)
23+
print("✅ Testing GitHub token validation...")
24+
try:
25+
git_utils.validate_github_token("ghp_" + "A" * 36)
26+
print(" ✓ Valid token accepted")
27+
except Exception as e:
28+
print(f" ✗ Token validation failed: {e}")
29+
30+
# Test 2: Test GitHub host detection
31+
print("✅ Testing GitHub host detection...")
32+
assert git_utils.is_github_host("https://github.com/owner/repo") == True
33+
assert git_utils.is_github_host("https://gitlab.com/owner/repo") == False
34+
print(" ✓ GitHub host detection works")
35+
36+
# Test 3: Test auth header creation
37+
print("✅ Testing auth header creation...")
38+
token = "ghp_" + "A" * 36
39+
header = git_utils.create_git_auth_header(token)
40+
assert "Authorization: Basic" in header
41+
assert "github.com" in header
42+
print(" ✓ Auth header creation works")
43+
44+
# Test 4: Test Git command creation with auth
45+
print("✅ Testing Git command creation...")
46+
git_cmd = git_utils.create_git_command_with_auth(token, "https://github.com/owner/repo")
47+
# Should have authentication configured
48+
assert hasattr(git_cmd, 'custom_environment'), "GitPython command should have custom environment"
49+
assert 'GIT_CONFIG_PARAMETERS' in git_cmd.custom_environment, "Should have auth parameters"
50+
print(" ✓ Git command with auth works")
51+
52+
git_cmd_no_auth = git_utils.create_git_command_with_auth(None, "https://github.com/owner/repo")
53+
# Should not have auth for no token
54+
assert not hasattr(git_cmd_no_auth, 'custom_environment') or 'GIT_CONFIG_PARAMETERS' not in (git_cmd_no_auth.custom_environment or {}), "Should not have auth without token"
55+
print(" ✓ Git command without auth works")
56+
57+
# Test 5: Test git installation check
58+
print("✅ Testing Git installation check...")
59+
try:
60+
await git_utils.ensure_git_installed()
61+
print(" ✓ Git is installed and accessible")
62+
except Exception as e:
63+
print(f" ✗ Git installation check failed: {e}")
64+
65+
print("\n🎉 All basic tests passed! GitPython integration is working.")
66+
67+
68+
if __name__ == "__main__":
69+
asyncio.run(test_basic_functions())

0 commit comments

Comments
 (0)