Skip to content

Commit fd6f983

Browse files
Python test fix
1 parent 8b473e8 commit fd6f983

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

python/copilot/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def __init__(self, options: Optional[CopilotClientOptions] = None):
152152
self._actual_port = None
153153

154154
# Determine CLI path: explicit option > bundled binary
155-
if opts.get("cli_path"):
155+
# Not needed when connecting to external server via cli_url
156+
if opts.get("cli_url"):
157+
default_cli_path = "" # Not used for external server
158+
elif opts.get("cli_path"):
156159
default_cli_path = opts["cli_path"]
157160
else:
158161
bundled_path = _get_bundled_cli_path()

python/test_client.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,36 @@ def test_is_external_server_true(self):
9696

9797
class TestAuthOptions:
9898
def test_accepts_github_token(self):
99-
client = CopilotClient({"github_token": "gho_test_token", "log_level": "error"})
99+
client = CopilotClient(
100+
{"cli_path": CLI_PATH, "github_token": "gho_test_token", "log_level": "error"}
101+
)
100102
assert client.options.get("github_token") == "gho_test_token"
101103

102104
def test_default_use_logged_in_user_true_without_token(self):
103-
client = CopilotClient({"log_level": "error"})
105+
client = CopilotClient({"cli_path": CLI_PATH, "log_level": "error"})
104106
assert client.options.get("use_logged_in_user") is True
105107

106108
def test_default_use_logged_in_user_false_with_token(self):
107-
client = CopilotClient({"github_token": "gho_test_token", "log_level": "error"})
109+
client = CopilotClient(
110+
{"cli_path": CLI_PATH, "github_token": "gho_test_token", "log_level": "error"}
111+
)
108112
assert client.options.get("use_logged_in_user") is False
109113

110114
def test_explicit_use_logged_in_user_true_with_token(self):
111115
client = CopilotClient(
112-
{"github_token": "gho_test_token", "use_logged_in_user": True, "log_level": "error"}
116+
{
117+
"cli_path": CLI_PATH,
118+
"github_token": "gho_test_token",
119+
"use_logged_in_user": True,
120+
"log_level": "error",
121+
}
113122
)
114123
assert client.options.get("use_logged_in_user") is True
115124

116125
def test_explicit_use_logged_in_user_false_without_token(self):
117-
client = CopilotClient({"use_logged_in_user": False, "log_level": "error"})
126+
client = CopilotClient(
127+
{"cli_path": CLI_PATH, "use_logged_in_user": False, "log_level": "error"}
128+
)
118129
assert client.options.get("use_logged_in_user") is False
119130

120131
def test_github_token_with_cli_url_raises(self):

0 commit comments

Comments
 (0)