Skip to content

Commit c083469

Browse files
committed
ruff
1 parent e910159 commit c083469

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

tests/test_consume.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,19 @@ def test_consume_but_exception_thrown_consumer_is_closed():
8383
consume("somebroker", "sometopic", num_messages=1)
8484
c.return_value.close.assert_called_once()
8585

86+
8687
@patch("saluki.consume.Consumer")
8788
def test_consume_with_timestamp(mock_consumer):
8889
expected_topic = "sometopic"
8990
partition = 0
9091
timestamp = 1234
9192
offset = 2345
9293

93-
mock_consumer.offsets_for_times.return_value = [TopicPartition(expected_topic, partition, offset)]
94+
mock_consumer.offsets_for_times.return_value = [
95+
TopicPartition(expected_topic, partition, offset)
96+
]
9497
consume("somebroker", topic=expected_topic, timestamp=timestamp, partition=partition)
9598

96-
mock_consumer.return_value.assign.assert_called_with([TopicPartition(expected_topic, partition, offset)])
99+
mock_consumer.return_value.assign.assert_called_with(
100+
[TopicPartition(expected_topic, partition, offset)]
101+
)

tests/test_play.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def test_play_with_offsets():
3939
p_obj = p()
4040
produce_batch_call = p_obj.produce_batch.call_args.args
4141
assert dest_topic == produce_batch_call[0]
42-
assert {'key': message_1_key, 'value': message_1_val} in produce_batch_call[1]
43-
assert {'key': message_2_key, 'value': message_2_val} in produce_batch_call[1]
42+
assert {"key": message_1_key, "value": message_1_val} in produce_batch_call[1]
43+
assert {"key": message_2_key, "value": message_2_val} in produce_batch_call[1]
4444

4545

4646
def test_play_with_timestamps():
@@ -66,7 +66,7 @@ def test_play_with_timestamps():
6666
consumer_obj = c()
6767
consumer_obj.offsets_for_times.side_effect = [
6868
[TopicPartition(src_topic, partition=0, offset=2)],
69-
[TopicPartition(src_topic, partition=0, offset=3)]
69+
[TopicPartition(src_topic, partition=0, offset=3)],
7070
]
7171
consumer_obj.consume.return_value = [message_1, message_2]
7272

@@ -80,8 +80,8 @@ def test_play_with_timestamps():
8080
p_obj = p()
8181
produce_batch_call = p_obj.produce_batch.call_args.args
8282
assert dest_topic == produce_batch_call[0]
83-
assert {'key': message_1_key, 'value': message_1_val} in produce_batch_call[1]
84-
assert {'key': message_2_key, 'value': message_2_val} in produce_batch_call[1]
83+
assert {"key": message_1_key, "value": message_1_val} in produce_batch_call[1]
84+
assert {"key": message_2_key, "value": message_2_val} in produce_batch_call[1]
8585

8686

8787
def test_play_with_exception_when_consuming_consumer_still_closed():

tests/test_utils.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
from saluki.utils import (
1414
_parse_timestamp,
1515
_try_to_deserialise_message,
16+
dateutil_parsable_or_unix_timestamp,
1617
deserialise_and_print_messages,
17-
parse_kafka_uri, dateutil_parsable_or_unix_timestamp,
18+
parse_kafka_uri,
1819
)
1920

2021

@@ -176,26 +177,26 @@ def test_uri_with_no_topic():
176177
with pytest.raises(RuntimeError):
177178
parse_kafka_uri(test_broker)
178179

179-
@pytest.mark.parametrize("timestamp",
180-
["2025-11-19T15:27:11",
181-
"2025-11-19T15:27:11Z",
182-
"2025-11-19T15:27:11+00:00"
183-
]
184180

181+
@pytest.mark.parametrize(
182+
"timestamp", ["2025-11-19T15:27:11", "2025-11-19T15:27:11Z", "2025-11-19T15:27:11+00:00"]
185183
)
186184
def test_parses_datetime_properly_with_string(timestamp):
187185
assert dateutil_parsable_or_unix_timestamp(timestamp) == 1763566031000
188186

189-
@pytest.mark.parametrize("timestamp",
190-
["1763566031000",
191-
"1763566031",
192-
"1763566031000000",
193-
]
187+
188+
@pytest.mark.parametrize(
189+
"timestamp",
190+
[
191+
"1763566031000",
192+
"1763566031",
193+
"1763566031000000",
194+
],
194195
)
195196
def test_parses_datetime_properly_and_leaves_unix_timestamp_alone(timestamp):
196197
assert dateutil_parsable_or_unix_timestamp(timestamp) == int(timestamp)
197198

198199

199200
def test_invalid_timestamp_raises():
200201
with pytest.raises(ArgumentTypeError):
201-
dateutil_parsable_or_unix_timestamp("invalid")
202+
dateutil_parsable_or_unix_timestamp("invalid")

0 commit comments

Comments
 (0)