Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tests/test_pairing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import importlib
import importlib.util
import io
import json
Expand Down Expand Up @@ -84,7 +85,7 @@ def test_a_named_profile_is_in_the_gateway_name(tmp_path):
def test_an_unnamed_pairing_takes_the_bots_name(tmp_path, monkeypatch):
# Not the container's id a Docker host's name is (issue 2540).
client = api.self_update._plugin_client()
titles = sys.modules[f"{client.__package__}.session_titles"]
titles = importlib.import_module(f"{client.__package__}.session_titles")
monkeypatch.setattr(titles, "bot_name", lambda: "Cortana")
calls = []
api.pairing.pair_profile({"pairing_code": CODE}, profile="coder", path=tmp_path / "s.json", claim=_recording_claim(calls))
Expand All @@ -108,6 +109,22 @@ def test_an_unnamed_pairing_takes_the_bots_name(tmp_path, monkeypatch):
assert sent[-1]["gateway_name"] == "Studio"


def test_an_unnamed_profile_comes_from_the_dashboards_home(tmp_path, monkeypatch):
# A dashboard scoped to a named profile names the gateway as the CLI does.
client = api.self_update._plugin_client()
titles = importlib.import_module(f"{client.__package__}.session_titles")
monkeypatch.setattr(titles, "bot_name", lambda: "")
monkeypatch.setattr(titles, "_home", lambda: tmp_path / "profiles" / "work")
calls = []
for profile in (None, "", "current"):
api.pairing.pair_profile({"pairing_code": CODE}, profile=profile, path=tmp_path / "s.json",
claim=_recording_claim(calls))
assert calls[-1][2] == "box Hermes (work)", profile
assert client.default_gateway_name(profile) == "box Hermes (work)", profile
monkeypatch.setattr(titles, "_home", lambda: None)
assert client.default_gateway_name() == "box Hermes"


def test_a_plugin_that_wont_load_still_pairs_by_the_host_name(tmp_path, monkeypatch):
def broken():
raise ImportError("half-updated install")
Expand Down
Loading