Skip to content

Commit 99038af

Browse files
committed
ADD: Add client to auth request
1 parent a7c6f57 commit 99038af

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

databento/live/gateway.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from databento_dbn import SType
1313

1414
from databento.common.enums import Dataset
15+
from databento.version import __version__
1516

1617

1718
logger = logging.getLogger(__name__)
@@ -108,6 +109,7 @@ class AuthenticationRequest(GatewayControl):
108109
encoding: Encoding = Encoding.DBN
109110
details: str | None = None
110111
ts_out: str = "0"
112+
client: str = f"Python {__version__}"
111113

112114

113115
@dataclasses.dataclass

tests/test_live_gateway_messages.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from databento.live.gateway import Greeting
1010
from databento.live.gateway import SessionStart
1111
from databento.live.gateway import SubscriptionRequest
12+
from databento.version import __version__
1213
from databento_dbn import Encoding
1314
from databento_dbn import Schema
1415
from databento_dbn import SType
@@ -29,27 +30,29 @@
2930
"line, expected",
3031
[
3132
pytest.param(
32-
"auth=abcd1234|dataset=GLBX.MDP3|encoding=json\n",
33-
("abcd1234", "GLBX.MDP3", "json", None, "0"),
33+
f"auth=abcd1234|dataset=GLBX.MDP3|encoding=json|client=Python {__version__}\n",
34+
("abcd1234", "GLBX.MDP3", "json", None, "0", f"Python {__version__}"),
3435
),
3536
pytest.param(
36-
"auth=abcd1234|dataset=GLBX.MDP3|ts_out=1\n",
37+
f"auth=abcd1234|dataset=GLBX.MDP3|ts_out=1|client=Python {__version__}\n",
3738
(
3839
"abcd1234",
3940
"GLBX.MDP3",
4041
str(Encoding.DBN),
4142
None,
4243
"1",
44+
f"Python {__version__}",
4345
),
4446
),
4547
pytest.param(
46-
"auth=abcd1234|dataset=XNAS.ITCH\n",
48+
f"auth=abcd1234|dataset=XNAS.ITCH|client=Python {__version__}\n",
4749
(
4850
"abcd1234",
4951
"XNAS.ITCH",
5052
str(Encoding.DBN),
5153
None,
5254
"0",
55+
f"Python {__version__}",
5356
),
5457
),
5558
pytest.param(
@@ -73,6 +76,7 @@ def test_parse_authentication_request(
7376
msg.encoding,
7477
msg.details,
7578
msg.ts_out,
79+
msg.client,
7680
) == expected
7781
else:
7882
with pytest.raises(expected):
@@ -87,15 +91,15 @@ def test_parse_authentication_request(
8791
auth="abcd1234",
8892
dataset=Dataset.GLBX_MDP3,
8993
),
90-
b"auth=abcd1234|dataset=GLBX.MDP3|encoding=dbn|ts_out=0\n",
94+
f"auth=abcd1234|dataset=GLBX.MDP3|encoding=dbn|ts_out=0|client=Python {__version__}\n".encode(),
9195
),
9296
pytest.param(
9397
AuthenticationRequest(
9498
auth="abcd1234",
9599
dataset=Dataset.XNAS_ITCH,
96100
ts_out="1",
97101
),
98-
b"auth=abcd1234|dataset=XNAS.ITCH|encoding=dbn|ts_out=1\n",
102+
f"auth=abcd1234|dataset=XNAS.ITCH|encoding=dbn|ts_out=1|client=Python {__version__}\n".encode(),
99103
),
100104
],
101105
)

0 commit comments

Comments
 (0)