diff --git a/CHANGELOG.md b/CHANGELOG.md index 841d3740a..3b4160e41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,11 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. ### Added +- Added unit tests for `SubscriptionHandle` class covering cancellation state, thread management, and join operations. + + - 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) +- - Modularized `transfer_transaction_fungible` example by introducing `account_balance_query()` & `transfer_transaction()`.Renamed `transfer_tokens()` → `main()` - 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. - Added `__str__()` to CustomFixedFee and updated examples and tests accordingly. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67bfbb67c..b2974d7a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -166,4 +166,5 @@ Thank you for contributing to the Hiero Python SDK! 🎉 - **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 - **Quick Links:** - Join the main [Linux Foundation Decentralized Trust (LFDT) Discord Server](https://discord.gg/hyperledger). - - Go directly to the [#hiero-python-sdk channel](https://discord.com/channels/905194001349627914/1336494517544681563) \ No newline at end of file + - Go directly to the [#hiero-python-sdk channel](https://discord.com/channels/905194001349627914/1336494517544681563) + diff --git a/tests/unit/test_subscription_handle.py b/tests/unit/test_subscription_handle.py new file mode 100644 index 000000000..230680d6e --- /dev/null +++ b/tests/unit/test_subscription_handle.py @@ -0,0 +1,28 @@ +from unittest.mock import Mock + +from hiero_sdk_python.utils.subscription_handle import SubscriptionHandle + + +def test_not_cancelled_by_default(): + handle = SubscriptionHandle() + assert not handle.is_cancelled() + + +def test_cancel_marks_as_cancelled(): + handle = SubscriptionHandle() + handle.cancel() + assert handle.is_cancelled() + + +def test_set_thread_and_join_calls_thread_join_with_timeout(): + handle = SubscriptionHandle() + mock_thread = Mock() + handle.set_thread(mock_thread) + handle.join(timeout=0.25) + mock_thread.join.assert_called_once_with(0.25) + + +def test_join_without_thread_raises_nothing(): + handle = SubscriptionHandle() + # should not raise + handle.join()