Coverage for intelligence_toolkit/tests/unit/helpers/test_progress_batch_callback.py: 100%
34 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
1# Copyright (c) 2024 Microsoft Corporation. All rights reserved.
2# Licensed under the MIT license. See LICENSE file in the project.
3#
4import pytest
6from intelligence_toolkit.helpers.progress_batch_callback import ProgressBatchCallback
9def test_progress_batch_callback_initialization():
10 callback = ProgressBatchCallback()
12 assert callback.current_batch == 0
13 assert callback.total_batches == 0
16def test_progress_batch_callback_on_batch_change():
17 callback = ProgressBatchCallback()
19 callback.on_batch_change(5, 10)
21 assert callback.current_batch == 5
22 assert callback.total_batches == 10
25def test_progress_batch_callback_on_batch_change_with_message():
26 callback = ProgressBatchCallback()
28 callback.on_batch_change(3, 7, message="Processing...")
30 assert callback.current_batch == 3
31 assert callback.total_batches == 7
32 assert callback.message == "Processing..."
35def test_progress_batch_callback_multiple_updates():
36 callback = ProgressBatchCallback()
38 callback.on_batch_change(1, 10)
39 assert callback.current_batch == 1
41 callback.on_batch_change(5, 10)
42 assert callback.current_batch == 5
44 callback.on_batch_change(10, 10)
45 assert callback.current_batch == 10
48def test_progress_batch_callback_message_attribute_exists():
49 callback = ProgressBatchCallback()
50 callback.on_batch_change(1, 1, message="test")
52 assert hasattr(callback, 'message')
53 assert callback.message == "test"
56def test_progress_batch_callback_default_message():
57 callback = ProgressBatchCallback()
58 callback.on_batch_change(1, 1)
60 # Default message is empty string
61 assert callback.message == ""