-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
86 lines (69 loc) · 2.52 KB
/
conftest.py
File metadata and controls
86 lines (69 loc) · 2.52 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
# pylint: disable=wrong-import-position
import os
import random
os.environ.setdefault("GITAUTO_API_KEY", "test-api-key")
import pytest
from constants.models import ModelId, USER_SELECTABLE_MODELS
from services.github.token.get_installation_token import get_installation_access_token
from services.types.base_args import BaseArgs
# Test constants as fixtures
@pytest.fixture
def test_owner():
return "gitautoai"
@pytest.fixture
def test_repo():
return "gitauto"
@pytest.fixture
def test_forked_repo():
return "DeepSeek-R1"
@pytest.fixture
def test_installation_id():
return 60314628
# Session scope to avoid GitHub API rate limiting on CI - 1 call per run, not per test
@pytest.fixture(scope="session")
def test_token():
return get_installation_access_token(installation_id=60314628)
# Helper function as fixture - returns a function that can be called with overrides
@pytest.fixture
def create_test_base_args():
def _create(*, model_id: ModelId | None = None, **overrides) -> BaseArgs:
selected: ModelId = (
model_id
if model_id is not None
else random.choice(list(USER_SELECTABLE_MODELS))
)
defaults: BaseArgs = {
"owner_type": "User",
"owner_id": random.randint(1, 999999),
"owner": "test-owner",
"repo_id": random.randint(1, 999999),
"repo": "test-repo",
"clone_url": "https://x-access-token:test-token@github.com/test-owner/test-repo.git",
"is_fork": False,
"pr_number": random.randint(1, 9999),
"pr_title": "Test Issue",
"pr_body": "Test PR body",
"pr_comments": [],
"latest_commit_sha": "abc123",
"pr_creator": "test-user",
"base_branch": "main",
"new_branch": "test-branch",
"installation_id": random.randint(1, 999999),
"token": "test-token",
"sender_id": random.randint(1, 999999),
"sender_name": "test-sender",
"sender_email": "test@example.com",
"sender_display_name": "Test Sender",
"reviewers": [],
"github_urls": [],
"other_urls": [],
"clone_dir": "/tmp/test-owner/test-repo/pr-123",
"model_id": selected,
"verify_consecutive_failures": 0,
"quality_gate_fail_count": 0,
}
# Apply any overrides
for key, value in overrides.items():
defaults[key] = value
return defaults
return _create