Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion teslemetry_stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ async def connect(self) -> None:
if self.vin:
url += f"/{self.vin}"
headers = await self.headers()
params = {"topics": ",".join(self.topics)} if self.topics else None
# Explicit so the connect-time snapshot survives the server default changing.
params = {"cache": "true"}
if self.topics:
params["topics"] = ",".join(self.topics)
response = await self._session.get(
url,
headers=headers,
Expand Down
12 changes: 6 additions & 6 deletions tests/test_sse_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def main() -> None:
asyncio.run(stream.connect())
results.append(
check(
"omitted topics sends no topics query param",
session.calls[0]["params"] is None,
"omitted topics sends only cache=true",
session.calls[0]["params"] == {"cache": "true"},
f"got {session.calls[0]['params']}",
)
)
Expand All @@ -109,7 +109,7 @@ def main() -> None:
results.append(
check(
"topics builds a comma-separated params entry",
session.calls[0]["params"] == {"topics": "live_status,site_info"},
session.calls[0]["params"] == {"cache": "true", "topics": "live_status,site_info"},
f"got {session.calls[0]['params']}",
)
)
Expand All @@ -120,7 +120,7 @@ def main() -> None:
results.append(
check(
"plain string topics are accepted",
session.calls[0]["params"] == {"topics": "state,config"},
session.calls[0]["params"] == {"cache": "true", "topics": "state,config"},
f"got {session.calls[0]['params']}",
)
)
Expand All @@ -144,7 +144,7 @@ def main() -> None:
results.append(
check(
"a bare str topics value is treated as a single topic, not character-split",
session.calls[0]["params"] == {"topics": "state"},
session.calls[0]["params"] == {"cache": "true", "topics": "state"},
f"got {session.calls[0]['params']}",
)
)
Expand All @@ -155,7 +155,7 @@ def main() -> None:
results.append(
check(
"a bare SseTopic topics value is treated as a single topic, not character-split",
session.calls[0]["params"] == {"topics": "live_status"},
session.calls[0]["params"] == {"cache": "true", "topics": "live_status"},
f"got {session.calls[0]['params']}",
)
)
Expand Down
Loading