Skip to content

Commit 4ac6e38

Browse files
authored
Test the dashboard's own profile in an unnamed pairing's gateway name (#855)
Covers a dashboard scoped to profiles/work with an unnamed bot pairing with the profile missing, empty or current. The pairing tests import session_titles themselves, so they pass when run alone.
1 parent 623351f commit 4ac6e38

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎tests/test_pairing.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import importlib
23
import importlib.util
34
import io
45
import json
@@ -84,7 +85,7 @@ def test_a_named_profile_is_in_the_gateway_name(tmp_path):
8485
def test_an_unnamed_pairing_takes_the_bots_name(tmp_path, monkeypatch):
8586
# Not the container's id a Docker host's name is (issue 2540).
8687
client = api.self_update._plugin_client()
87-
titles = sys.modules[f"{client.__package__}.session_titles"]
88+
titles = importlib.import_module(f"{client.__package__}.session_titles")
8889
monkeypatch.setattr(titles, "bot_name", lambda: "Cortana")
8990
calls = []
9091
api.pairing.pair_profile({"pairing_code": CODE}, profile="coder", path=tmp_path / "s.json", claim=_recording_claim(calls))
@@ -108,6 +109,22 @@ def test_an_unnamed_pairing_takes_the_bots_name(tmp_path, monkeypatch):
108109
assert sent[-1]["gateway_name"] == "Studio"
109110

110111

112+
def test_an_unnamed_profile_comes_from_the_dashboards_home(tmp_path, monkeypatch):
113+
# A dashboard scoped to a named profile names the gateway as the CLI does.
114+
client = api.self_update._plugin_client()
115+
titles = importlib.import_module(f"{client.__package__}.session_titles")
116+
monkeypatch.setattr(titles, "bot_name", lambda: "")
117+
monkeypatch.setattr(titles, "_home", lambda: tmp_path / "profiles" / "work")
118+
calls = []
119+
for profile in (None, "", "current"):
120+
api.pairing.pair_profile({"pairing_code": CODE}, profile=profile, path=tmp_path / "s.json",
121+
claim=_recording_claim(calls))
122+
assert calls[-1][2] == "box Hermes (work)", profile
123+
assert client.default_gateway_name(profile) == "box Hermes (work)", profile
124+
monkeypatch.setattr(titles, "_home", lambda: None)
125+
assert client.default_gateway_name() == "box Hermes"
126+
127+
111128
def test_a_plugin_that_wont_load_still_pairs_by_the_host_name(tmp_path, monkeypatch):
112129
def broken():
113130
raise ImportError("half-updated install")

0 commit comments

Comments
 (0)