Set up the test context with a shared client. Args: cli_args: Optional extra CLI arguments passed to the CLI process.
(self, cli_args: list[str] | None = None)
| 58 | self._client: CopilotClient | None = None |
| 59 | |
| 60 | async def setup(self, cli_args: list[str] | None = None): |
| 61 | """Set up the test context with a shared client. |
| 62 | |
| 63 | Args: |
| 64 | cli_args: Optional extra CLI arguments passed to the CLI process. |
| 65 | """ |
| 66 | self.cli_path = get_cli_path_for_tests() |
| 67 | |
| 68 | self.home_dir = os.path.realpath(tempfile.mkdtemp(prefix="copilot-test-config-")) |
| 69 | self.work_dir = os.path.realpath(tempfile.mkdtemp(prefix="copilot-test-work-")) |
| 70 | |
| 71 | self._proxy = CapiProxy() |
| 72 | self.proxy_url = await self._proxy.start() |
| 73 | await self._proxy.set_copilot_user_by_token( |
| 74 | DEFAULT_GITHUB_TOKEN, |
| 75 | { |
| 76 | "login": "e2e-test-user", |
| 77 | "copilot_plan": "individual_pro", |
| 78 | "endpoints": { |
| 79 | "api": self.proxy_url, |
| 80 | "telemetry": "https://localhost:1/telemetry", |
| 81 | }, |
| 82 | "analytics_tracking_id": "e2e-test-tracking-id", |
| 83 | }, |
| 84 | ) |
| 85 | |
| 86 | # Create the shared client (like Node.js/Go do) |
| 87 | self._client = CopilotClient( |
| 88 | connection=RuntimeConnection.for_stdio( |
| 89 | path=self.cli_path, |
| 90 | args=tuple(cli_args or []), |
| 91 | ), |
| 92 | working_directory=self.work_dir, |
| 93 | env=self.get_env(), |
| 94 | github_token=DEFAULT_GITHUB_TOKEN, |
| 95 | ) |
| 96 | |
| 97 | async def teardown(self, test_failed: bool = False): |
| 98 | """Clean up the test context. |