Skip to content

Commit eab5ea7

Browse files
authored
test: add unit test for subscription_handle (#1028)
Signed-off-by: Giannis <giannisgeorgiadiis@gmail.com> Signed-off-by: GiannisGeo <giannisgeorgiadiis@gmail.com>
1 parent cfc86ba commit eab5ea7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
88

99
### Added
1010

11+
- Added unit tests for `SubscriptionHandle` class covering cancellation state, thread management, and join operations.
12+
13+
1114
- Refactored `account_create_transaction_create_with_alias.py` example by splitting monolithic function into modular functions: `generate_main_and_alias_keys()`, `create_account_with_ecdsa_alias()`, `fetch_account_info()`, `print_account_summary()` (#1016)
15+
-
1216
- Modularized `transfer_transaction_fungible` example by introducing `account_balance_query()` & `transfer_transaction()`.Renamed `transfer_tokens()``main()`
1317
- Phase 2 of the inactivity-unassign bot: Automatically detects stale open pull requests (no commit activity for 21+ days), comments with a helpful InactivityBot message, closes the stale PR, and unassigns the contributor from the linked issue.
1418
- Added `__str__()` to CustomFixedFee and updated examples and tests accordingly.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,5 @@ Thank you for contributing to the Hiero Python SDK! 🎉
166166
- **Need help or want to connect?** Join our community on Discord! See the **[Discord Joining Guide](docs/discord.md)** for detailed steps on how to join the LFDT server
167167
- **Quick Links:**
168168
- Join the main [Linux Foundation Decentralized Trust (LFDT) Discord Server](https://discord.gg/hyperledger).
169-
- Go directly to the [#hiero-python-sdk channel](https://discord.com/channels/905194001349627914/1336494517544681563)
169+
- Go directly to the [#hiero-python-sdk channel](https://discord.com/channels/905194001349627914/1336494517544681563)
170+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from unittest.mock import Mock
2+
3+
from hiero_sdk_python.utils.subscription_handle import SubscriptionHandle
4+
5+
6+
def test_not_cancelled_by_default():
7+
handle = SubscriptionHandle()
8+
assert not handle.is_cancelled()
9+
10+
11+
def test_cancel_marks_as_cancelled():
12+
handle = SubscriptionHandle()
13+
handle.cancel()
14+
assert handle.is_cancelled()
15+
16+
17+
def test_set_thread_and_join_calls_thread_join_with_timeout():
18+
handle = SubscriptionHandle()
19+
mock_thread = Mock()
20+
handle.set_thread(mock_thread)
21+
handle.join(timeout=0.25)
22+
mock_thread.join.assert_called_once_with(0.25)
23+
24+
25+
def test_join_without_thread_raises_nothing():
26+
handle = SubscriptionHandle()
27+
# should not raise
28+
handle.join()

0 commit comments

Comments
 (0)