Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
copilot-sdk/python/e2e/test_client_api_e2e.py at main · github/copilot-sdk · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
github
copilot-sdk
Repository navigation
Code
Issues
305
(305)
Pull requests
27
(27)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
copilot-sdk
/
python
/
e2e
/
test_client_api_e2e.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
87 lines (69 loc) · 3.24 KB
main
Breadcrumbs
copilot-sdk
/
python
/
e2e
/
test_client_api_e2e.py
Copy path
Top
File metadata and controls
Code
Blame
87 lines (69 loc) · 3.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
87
"""
Tests for client-scoped session-management APIs:
``delete_session``, ``get_session_metadata``, ``get_last_session_id``,
``get_foreground_session_id``, and ``set_foreground_session_id``.
The file is named ``test_client_api`` so the conftest snapshot resolver picks
up the ``test/snapshots/client_api`` folder shared with the C# suite
(``ClientSessionManagementTests.cs``).
"""
from
__future__
import
annotations
import
pytest
from
copilot
.
session
import
PermissionHandler
from
.
testharness
import
E2ETestContext
pytestmark
=
pytest
.
mark
.
asyncio
(
loop_scope
=
"module"
)
class
TestClientApi
:
async
def
test_should_delete_session_by_id
(
self
,
ctx
:
E2ETestContext
):
session
=
await
ctx
.
client
.
create_session
(
on_permission_request
=
PermissionHandler
.
approve_all
,
)
session_id
=
session
.
session_id
await
session
.
send_and_wait
(
"Say OK."
)
await
session
.
disconnect
()
await
ctx
.
client
.
delete_session
(
session_id
)
metadata
=
await
ctx
.
client
.
get_session_metadata
(
session_id
)
assert
metadata
is
None
async
def
test_should_report_error_when_deleting_unknown_session_id
(
self
,
ctx
:
E2ETestContext
):
await
ctx
.
client
.
start
()
unknown_session_id
=
"00000000-0000-0000-0000-000000000000"
with
pytest
.
raises
(
Exception
)
as
exc_info
:
await
ctx
.
client
.
delete_session
(
unknown_session_id
)
assert
f"failed to delete session
{
unknown_session_id
}
"
in
str
(
exc_info
.
value
).
lower
()
async
def
test_should_get_null_last_session_id_before_any_sessions_exist
(
self
,
ctx
:
E2ETestContext
):
await
ctx
.
client
.
start
()
# Other tests in this class create sessions, and pytest doesn't
# guarantee test execution order. Clear any leftover sessions so this
# test sees a genuinely empty state regardless of order.
for
existing
in
await
ctx
.
client
.
list_sessions
():
await
ctx
.
client
.
delete_session
(
existing
.
session_id
)
result
=
await
ctx
.
client
.
get_last_session_id
()
assert
result
is
None
async
def
test_should_track_last_session_id_after_session_created
(
self
,
ctx
:
E2ETestContext
):
session
=
await
ctx
.
client
.
create_session
(
on_permission_request
=
PermissionHandler
.
approve_all
,
)
await
session
.
send_and_wait
(
"Say OK."
)
session_id
=
session
.
session_id
await
session
.
disconnect
()
last_id
=
await
ctx
.
client
.
get_last_session_id
()
assert
last_id
==
session_id
async
def
test_should_get_null_foreground_session_id_in_headless_mode
(
self
,
ctx
:
E2ETestContext
):
await
ctx
.
client
.
start
()
session_id
=
await
ctx
.
client
.
get_foreground_session_id
()
assert
session_id
is
None
async
def
test_should_report_error_when_setting_foreground_session_in_headless_mode
(
self
,
ctx
:
E2ETestContext
):
session
=
await
ctx
.
client
.
create_session
(
on_permission_request
=
PermissionHandler
.
approve_all
,
)
try
:
with
pytest
.
raises
(
Exception
)
as
exc_info
:
await
ctx
.
client
.
set_foreground_session_id
(
session
.
session_id
)
err
=
str
(
exc_info
.
value
).
lower
()
assert
"tui"
in
err
or
"server"
in
err
finally
:
await
session
.
disconnect
()
You can’t perform that action at this time.