AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
test: isolate ambient xurl credentials and memory paths (#1158)
Adam Shapiraa7809799106c
diff --git a/tests/conftest.py b/tests/conftest.pyindex 35143b44..6a973faf 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -33,6 +33,37 @@ def _no_ambient_grok_cli():yield[email protected](autouse=True)+def _no_ambient_xurl_store(tmp_path_factory, monkeypatch):+ """Point HOME at an empty directory so no test resolves the developer's own+ xurl token store, for the same reason as the grok fixture above. xurl is an+ X-chain backend whose auth evidence is a plain filesystem check, so anyone+ who has ever run xurl has a populated ``~/.xurl`` and silently resolves+ xurl as a configured backend in tests that assume none is present.++ Observed with a populated store: three test_grok_surfacing doctor cases+ report ``status == "ok"`` instead of ``"unconfigured"``, and+ test_backend_descriptors.TestGetXSourceStatusGrokPin+ .test_unpinned_with_store_does_not_return_grok_source fails+ ``assert status["source"] is None`` with ``'xurl'``.++ Stubbing ``xurl_x.has_stored_auth`` is not enough, and three of those tests+ already do it: ``backends._xurl_finding`` calls ``stored_auth_status()``+ directly, so the real store is still read. Stubbing ``token_store_path``+ instead breaks the tests that assert on it.++ Stub the input (where HOME points), not the logic: ``token_store_path``,+ ``stored_auth_status`` and ``has_stored_auth`` all run their real code and+ resolve absent on their own, and a test asserting+ ``Path.home() / ".xurl" / "auth.yml"`` still agrees with them because both+ sides move together. Tests that want a populated store write one under the+ redirected home, as they already do."""+ home = tmp_path_factory.mktemp("home")+ monkeypatch.setenv("HOME", str(home))+ monkeypatch.setenv("USERPROFILE", str(home))+ yield++@pytest.fixture(autouse=True)def _reset_probe_caches():"""The doctor stack memoizes probe results in module-level dicts (safe fordiff --git a/tests/test_setup_wizard.py b/tests/test_setup_wizard.pyindex 99d107f2..ecbb66fa 100644--- a/tests/test_setup_wizard.py+++ b/tests/test_setup_wizard.py@@ -362,10 +362,12 @@ class TestDiggAutoInstall:# Redirect HOME/GOPATH so real ~/.local/bin or ~/go/bin digg-pp-cli on the# dev box does not make the binary look present during absence tests.+ # USERPROFILE too: Path.home() reads it on Windows, and the two must agree.@staticmethoddef _empty_home(tmp_path, monkeypatch):monkeypatch.delenv("GOPATH", raising=False)monkeypatch.setenv("HOME", str(tmp_path))+ monkeypatch.setenv("USERPROFILE", str(tmp_path))@patch("lib.cookie_extract.extract_cookies_with_source", return_value=None)@patch("shutil.which")diff --git a/tests/test_skill_memory_directory.py b/tests/test_skill_memory_directory.pyindex 86d5be78..a690f1e1 100644--- a/tests/test_skill_memory_directory.py+++ b/tests/test_skill_memory_directory.py@@ -18,13 +18,15 @@ BASH = shutil.which("bash")@pytest.fixturedef shell_env(tmp_path):+ home = tmp_path / "home"+ home.mkdir()config_dir = tmp_path / "config"config_dir.mkdir()bin_dir = tmp_path / "bin"bin_dir.mkdir()return {"PATH": str(bin_dir),- "HOME": str(Path.home()),+ "HOME": str(home),"LAST30DAYS_PYTHON": sys.executable,"SKILL_DIR": str(SKILL),"LAST30DAYS_CONFIG_DIR": str(config_dir),@@ -45,17 +47,19 @@ def write_config(path, text):("/tmp/global", "/tmp/process research", "/tmp/process research"),("/tmp/global", "", ""),("", None, ""),- (None, None, str(Path.home() / "Documents" / "Last30Days")),+ (None, None, None),("/tmp/configured research", "${user_config.memory_dir}", "/tmp/configured research"),("", "${user_config.memory_dir}", ""),- (None, "${user_config.memory_dir}", str(Path.home() / "Documents" / "Last30Days")),- ("${user_config.memory_dir}", None, str(Path.home() / "Documents" / "Last30Days")),+ (None, "${user_config.memory_dir}", None),+ ("${user_config.memory_dir}", None, None),("${user_config.memory_dir}", "", ""),("/tmp/configured research", " ${user_config.memory_dir} ", "/tmp/configured research"),(None, "/tmp/${user_config.memory_dir}/research", "/tmp/${user_config.memory_dir}/research"),],)def test_documented_memory_resolution(global_value, process_value, expected, shell_env, tmp_path):+ if expected is None:+ expected = str(Path(shell_env["HOME"]) / "Documents" / "Last30Days")if global_value is not None:write_config(Path(shell_env["LAST30DAYS_CONFIG_DIR"]) / ".env",diff --git a/tests/test_x_envelope.py b/tests/test_x_envelope.pyindex 43dd17c6..fbf74ea5 100644--- a/tests/test_x_envelope.py+++ b/tests/test_x_envelope.py@@ -516,6 +516,7 @@ class TestInputBounds:for directory in (home / ".grok", home / ".xurl", cfg):directory.mkdir(parents=True)monkeypatch.setenv("HOME", str(home))+ monkeypatch.setenv("USERPROFILE", str(home))monkeypatch.setattr(env, "CONFIG_DIR", cfg)monkeypatch.setattr(env, "CONFIG_FILE", cfg / ".env")for target in (home / ".grok" / "auth.json", home / ".xurl" / "tokens.json", cfg / "posts.json"):