-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest_error_resilience_e2e.py
More file actions
50 lines (38 loc) · 1.61 KB
/
test_error_resilience_e2e.py
File metadata and controls
50 lines (38 loc) · 1.61 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
"""E2E tests for session lifecycle error handling."""
from __future__ import annotations
import pytest
from copilot.session import PermissionHandler
from .testharness import E2ETestContext
pytestmark = pytest.mark.asyncio(loop_scope="module")
class TestErrorResilience:
async def test_should_throw_when_sending_to_disconnected_session(self, ctx: E2ETestContext):
session = await ctx.client.create_session(
on_permission_request=PermissionHandler.approve_all
)
await session.disconnect()
with pytest.raises(Exception):
await session.send_and_wait("Hello")
async def test_should_throw_when_getting_messages_from_disconnected_session(
self, ctx: E2ETestContext
):
session = await ctx.client.create_session(
on_permission_request=PermissionHandler.approve_all
)
await session.disconnect()
with pytest.raises(Exception):
await session.get_events()
async def test_should_handle_double_abort_without_error(self, ctx: E2ETestContext):
session = await ctx.client.create_session(
on_permission_request=PermissionHandler.approve_all
)
try:
await session.abort()
await session.abort()
finally:
await session.disconnect()
async def test_should_throw_when_resuming_non_existent_session(self, ctx: E2ETestContext):
with pytest.raises(Exception):
await ctx.client.resume_session(
"non-existent-session-id-12345",
on_permission_request=PermissionHandler.approve_all,
)