"""`/api/me` names the live-search source, so the search button's tooltip can say what a search costs under the source that actually runs (the default website source spends no API quota).""" from app import sysconfig _PW = "correct horse battery" def _me(client): r = client.get("/api/me") assert r.status_code == 200 and r.json()["authenticated"] is True return r.json() def test_me_names_the_running_search_source(client, db, make_user): # /api/me resolves its user through optional_current_user, which the as_user override does not # cover — so sign in for real (see test_me_email_flag). user = make_user(password=_PW) login = client.post("/auth/password-login", json={"email": user.email, "password": _PW}) assert login.status_code == 200 assert _me(client)["search_source"] == "scrape" # the default sysconfig.set_value(db, "search_source", "api") db.commit() assert _me(client)["search_source"] == "api"