Skip to content

Commit

Permalink
FIX: Fix incorrect error message on start()
Browse files Browse the repository at this point in the history
  • Loading branch information
nmacholl committed Aug 1, 2023
1 parent 7b63ae3 commit 05f5ebf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.16.1 - TBD

#### Bug fixes
- Fixed an issue where starting a `Live` client before subscribing gave an incorrect error message

## 0.16.0 - 2023-07-25

This release includes updates to the fields in text encodings (CSV and JSON), you can read more about the changes [here](https://databento.com/blog/CSV-JSON-updates-july-2023).
Expand Down
3 changes: 3 additions & 0 deletions databento/live/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def start(
ValueError
If `start()` is called before a subscription has been made.
If `start()` is called after streaming has already started.
If `start()` is called after the live session has closed.
See Also
--------
Expand All @@ -365,6 +366,8 @@ def start(
"""
logger.info("starting live client")
if not self.is_connected():
if self.dataset == "":
raise ValueError("cannot start a live client without a subscription")
raise ValueError("cannot start a live client after it is closed")
if self._session.is_started():
raise ValueError("client is already started")
Expand Down
2 changes: 1 addition & 1 deletion databento/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.16.0"
__version__ = "0.16.1"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "databento"
version = "0.16.0"
version = "0.16.1"
description = "Official Python client library for Databento"
authors = [
"Databento <[email protected]>",
Expand Down
8 changes: 8 additions & 0 deletions tests/test_live_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ def test_live_start_twice(
with pytest.raises(ValueError):
live_client.start()

def test_live_start_before_subscribe(
live_client: client.Live,
) -> None:
"""
Test that calling start() before subscribe raises a ValueError.
"""
with pytest.raises(ValueError):
live_client.start()

@pytest.mark.parametrize(
"schema",
Expand Down

0 comments on commit 05f5ebf

Please sign in to comment.