-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_github_telemetry_e2e.py
More file actions
57 lines (44 loc) · 1.93 KB
/
Copy pathtest_github_telemetry_e2e.py
File metadata and controls
57 lines (44 loc) · 1.93 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
"""Live CLI E2E coverage for forwarded GitHub telemetry notifications."""
from __future__ import annotations
import asyncio
import pytest
from copilot import CopilotClient, GitHubTelemetryNotification, RuntimeConnection
from copilot.session import PermissionHandler
from .testharness import DEFAULT_GITHUB_TOKEN, E2ETestContext
from .testharness.context import get_cli_path_for_tests
pytestmark = pytest.mark.asyncio(loop_scope="module")
class TestGitHubTelemetryE2E:
async def test_should_receive_session_start_github_telemetry(self, ctx: E2ETestContext):
received: list[GitHubTelemetryNotification] = []
def on_github_telemetry(notification: GitHubTelemetryNotification) -> None:
received.append(notification)
client = CopilotClient(
connection=RuntimeConnection.for_stdio(path=get_cli_path_for_tests(), args=()),
working_directory=ctx.work_dir,
env=ctx.get_env(),
github_token=DEFAULT_GITHUB_TOKEN,
on_github_telemetry=on_github_telemetry,
)
session = None
try:
await client.start()
session = await client.create_session(
on_permission_request=PermissionHandler.approve_all,
)
for _ in range(600):
if received:
break
await asyncio.sleep(0.05)
assert received
notification = received[0]
assert isinstance(notification.session_id, str)
assert notification.session_id
assert isinstance(notification.restricted, bool)
assert notification.event is not None
assert isinstance(notification.event.kind, str)
finally:
try:
if session is not None:
await session.disconnect()
finally:
await client.stop()