"""Integration test fixtures and helpers for github_cli handler.""" from typing import Any import requests class MockResponse: """Minimal mock of requests.Response.""" def __init__(self, status_code: int = 200, json_data: Any = None) -> None: """Initialize the mock response.""" self.status_code = status_code self._json_data = json_data or {} self.headers: dict[str, str] = {} def raise_for_status(self) -> None: """Raise HTTPError for non-2xx status codes.""" if not (200 <= self.status_code < 300): raise requests.HTTPError(f'{self.status_code} error', response=self) def json(self) -> Any: """Return the JSON data.""" return self._json_data def make_search_item( path: str = 'modules/iam/users.tf', html_url: str = 'https://github.com/theorchard/terraform-infra/blob/master/modules/iam/users.tf', repo: str = 'theorchard/terraform-infra', ) -> dict: """Build a minimal GitHub code search result item.""" return { 'path': path, 'html_url': html_url, 'repository': {'full_name': repo}, } def make_search_event( email: str = 'jane@example.com', full_name: str = 'Jane Doe', org: str = 'theorchard', repo_filter: str = 'theorchard/terraform-infra', ticket_id: str = 'SYS-1', dry_run: bool = False, ) -> dict: """Build a search-text-in-org Lambda event.""" return { 'action': 'search-text-in-org', 'dry_run': dry_run, 'email': email, 'full_name': full_name, 'org': org, 'repo_filter': repo_filter, 'ticket_id': ticket_id, } def make_copilot_event( ticket_id: str = 'SYS-1', email: str = 'jane@example.com', full_name: str = 'Jane Doe', last_working_day: str = '2026-04-11', auth0_results: list | None = None, terraform_hits: list | None = None, repo: str | None = None, base_branch: str = 'master', operation: str = 'offboard', dry_run: bool = False, ) -> dict: """Build an offboard-user-with-copilot Lambda event.""" event: dict = { 'action': 'offboard-user-with-copilot', 'dry_run': dry_run, 'ticket_id': ticket_id, 'email': email, 'full_name': full_name, 'last_working_day': last_working_day, 'operation': operation, 'auth0_results': auth0_results or [], 'terraform_hits': terraform_hits or [], 'base_branch': base_branch, } if repo is not None: event['repo'] = repo return event