-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_manual.py
More file actions
93 lines (72 loc) Β· 3.39 KB
/
test_manual.py
File metadata and controls
93 lines (72 loc) Β· 3.39 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""Manual testing script for GitHub transform."""
import asyncio
import os
from spectragraph_transforms.social.github_repo import GitHubRepoTransform
async def test_github_transform():
"""Test the GitHub transform with real API calls."""
transform = GitHubRepoTransform()
# Manually inject params since we aren't using the full vault infra in this script
# User's token from previous context
token = os.environ.get("GITHUB_TOKEN")
if not token:
print("Error: GITHUB_TOKEN environment variable not set. Please run: export GITHUB_TOKEN='your_token'")
return
transform.params = {"github_token": token}
# Test 1: Basic scan
print("=== Test 1: Basic Domain Scan ===")
try:
# Preprocess manually (usually done by orchestrator)
input_data = ["anthropic.com"]
validated_input = await transform.preprocess(input_data)
print(f"β Preprocessing successful")
# Override default params for this run if needed, but since scan takes Values,
# config is in transform.params. Let's set max_repos there.
transform.params["max_repos"] = 5
results = await transform.scan(validated_input)
result = results[0]
print(f"β Found {len(result['organizations'])} organizations")
print(f"β Found {len(result['repositories'])} repositories")
print(f"β Found {len(result['contributors'])} contributors")
print(f"β Rate limit remaining: {result['metadata']['rate_limit']['remaining']}")
except Exception as e:
print(f"β Error: {e}")
import traceback
traceback.print_exc()
# Test 2: With filters
print("\n=== Test 2: Filtered Scan (OpenAI, Python, >100 stars) ===")
try:
transform.params["max_repos"] = 10
transform.params["min_stars"] = 100
transform.params["language_filter"] = "Python"
input_data = ["openai.com"]
validated_input = await transform.preprocess(input_data)
results = await transform.scan(validated_input)
result = results[0]
repos = result['repositories']
print(f"β Found {len(repos)} Python repos with 100+ stars")
if repos:
top_repo = max(repos, key=lambda r: r['stargazers_count'])
print(f"β Top repo: {top_repo['full_name']} ({top_repo['stargazers_count']} stars)")
except Exception as e:
print(f"β Error: {e}")
# Test 3: Include forks
print("\n=== Test 3: Include Forks (github.com) ===")
try:
transform.params["include_forks"] = True
transform.params["max_repos"] = 5
# Reset other filters
transform.params["min_stars"] = 0
transform.params["language_filter"] = None
input_data = ["github.com"]
validated_input = await transform.preprocess(input_data)
results = await transform.scan(validated_input)
result = results[0]
forks = [r for r in result['repositories'] if r['fork']]
originals = [r for r in result['repositories'] if not r['fork']]
print(f"β Total repos: {len(result['repositories'])}")
print(f"β Forks: {len(forks)}")
print(f"β Original: {len(originals)}")
except Exception as e:
print(f"β Error: {e}")
if __name__ == "__main__":
asyncio.run(test_github_transform())