-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathtest_refresh_custom_instructions.py
More file actions
39 lines (30 loc) · 1.37 KB
/
Copy pathtest_refresh_custom_instructions.py
File metadata and controls
39 lines (30 loc) · 1.37 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import inspect
from unittest.mock import AsyncMock, Mock
import pytest
from copilot import CopilotClient, RuntimeConnection
@pytest.mark.parametrize("refresh", [True, False, None], ids=["true", "false", "omitted"])
async def test_refresh_custom_instructions_is_create_only(refresh):
client = CopilotClient(connection=RuntimeConnection.for_uri("localhost:1234"))
request = AsyncMock(return_value={"sessionId": "refresh-instructions"})
client._client = Mock(request=request)
options = {} if refresh is None else {"refresh_custom_instructions": refresh}
await client.create_session(session_id="refresh-instructions", **options)
request.assert_awaited_once()
method, payload = request.call_args.args
assert method == "session.create"
if refresh is None:
assert "refreshCustomInstructions" not in payload
else:
assert payload.get("refreshCustomInstructions") is refresh
request.reset_mock()
await client.resume_session("refresh-instructions")
request.assert_awaited_once()
method, payload = request.call_args.args
assert method == "session.resume"
assert "refreshCustomInstructions" not in payload
assert (
"refresh_custom_instructions"
not in inspect.signature(CopilotClient.resume_session).parameters
)