Skip to content

Commit 2d25fb9

Browse files
committed
test: update Slack tests to expect integer timestamps
1 parent d033c8e commit 2d25fb9

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

app/connectors_service/tests/sources/test_slack.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ async def test_slack_data_source_get_docs(slack_data_source, mock_responses):
207207

208208
current_timestamp = time.time()
209209
with mock.patch("time.time", return_value=current_timestamp):
210-
old_timestamp = (
210+
old_timestamp = int(
211211
current_timestamp - configuration["fetch_last_n_days"] * 24 * 3600
212212
)
213+
current_timestamp = int(current_timestamp)
213214
docs = []
214215
async for doc, _ in slack_data_source.get_docs():
215216
docs.append(doc)
@@ -233,3 +234,31 @@ async def test_slack_data_source_convert_usernames(slack_data_source):
233234
remapped_message = slack_data_source.remap_message(message, channel)
234235

235236
assert remapped_message["text"] == "<@user_one> Hello, <@USERID2>"
237+
238+
@pytest.mark.asyncio
239+
async def test_channels_and_messages_uses_integer_timestamps(slack_data_source):
240+
"""
241+
Regression test for #3032
242+
Slack conversations.history API returns no messages when timestamps
243+
include decimal places. Verify timestamps are truncated to int.
244+
"""
245+
original_client = slack_data_source.slack_client
246+
await original_client.close()
247+
248+
mock_client = AsyncMock()
249+
mock_client.list_channels = AsyncIterator([{"id": "1", "name": "channel1", "is_member": True}])
250+
mock_client.list_messages = AsyncIterator([])
251+
mock_client.close = AsyncMock()
252+
slack_data_source.slack_client = mock_client
253+
254+
float_timestamp = 1745123456.561659
255+
with mock.patch("time.time", return_value=float_timestamp):
256+
async for _ in slack_data_source.channels_and_messages():
257+
pass
258+
259+
call_args = mock_client.list_messages.call_args
260+
oldest = call_args[0][1]
261+
latest = call_args[0][2]
262+
263+
assert isinstance(oldest, int), f"oldest timestamp should be int, got {type(oldest)}"
264+
assert isinstance(latest, int), f"latest timestamp should be int, got {type(latest)}"

0 commit comments

Comments
 (0)