Skip to content

Commit 42e6463

Browse files
committed
Add test for _ssboe_usecs_to_datetime
1 parent 7d5bd88 commit 42e6463

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

scripts/conformance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def main():
2121
await order_plant._connect()
2222
await order_plant._start_background_tasks()
2323
await order_plant._login()
24-
print("Logged in successfully")
24+
print("Logged in successfully. Press CTRL+C to exit")
2525

2626
print("Sleeping ...")
2727
await asyncio.sleep(3600)

tests/test_base.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest.mock import MagicMock
22
from datetime import datetime
33
import pytz
4+
import pytest
45

56
from async_rithmic.plants import TickerPlant
67
from async_rithmic import protocol_buffers as pb
@@ -43,14 +44,18 @@ def test_datetime_to_utc():
4344
dt = plant._datetime_to_utc(dt)
4445
assert dt == datetime(2024, 11, 8, 22, 29, 0, tzinfo=pytz.utc)
4546

46-
def test_ssboe_usecs_conversion():
47+
@pytest.mark.parametrize(
48+
"ssboe,usecs,expected_dt", [
49+
(1731092410, 164409, datetime(2024, 11, 8, 19, 0, 10, 164409, tzinfo=pytz.utc)),
50+
(1731092410, 123, datetime(2024, 11, 8, 19, 0, 10, 123, tzinfo=pytz.utc)),
51+
]
52+
)
53+
def test_ssboe_usecs_conversion(ssboe, usecs, expected_dt):
4754
plant = TickerPlant(MagicMock())
4855

49-
inputs = 1731092410, 164409
50-
51-
dt = plant._ssboe_usecs_to_datetime(*inputs)
52-
assert dt == datetime(2024, 11, 8, 19, 0, 10, 164409, tzinfo=pytz.utc)
56+
dt = plant._ssboe_usecs_to_datetime(ssboe, usecs)
57+
assert dt == expected_dt
5358

5459
output = plant._datetime_to_ssboe_usecs(dt)
55-
assert output == inputs
60+
assert output == (int(ssboe), int(usecs))
5661

0 commit comments

Comments
 (0)