11"""Focused createTopic tests for TCK handlers."""
2+
23from __future__ import annotations
34
45from unittest .mock import MagicMock , patch
2728
2829
2930def _params (** overrides ):
30- base = dict (sessionId = "test" , memo = None , adminKey = None , submitKey = None , autoRenewPeriod = None , autoRenewAccountId = None , feeScheduleKey = None , feeExemptKeys = None , customFees = None , commonTransactionParams = None )
31+ base = dict (
32+ sessionId = "test" ,
33+ memo = None ,
34+ adminKey = None ,
35+ submitKey = None ,
36+ autoRenewPeriod = None ,
37+ autoRenewAccountId = None ,
38+ feeScheduleKey = None ,
39+ feeExemptKeys = None ,
40+ customFees = None ,
41+ commonTransactionParams = None ,
42+ )
3143 base .update (overrides )
3244 return CreateTopicParams (** base )
3345
@@ -55,17 +67,40 @@ def test_parse_json_and_validation():
5567
5668
5769def test_build_custom_fee_and_reject_empty_collector ():
58- fee = _build_custom_fee (CreateTopicCustomFeeParams (feeCollectorAccountId = "0.0.98" , feeCollectorsExempt = True , fixedFee = CreateTopicFixedFeeParams (amount = 100 , denominatingTokenId = "0.0.500" )))
70+ fee = _build_custom_fee (
71+ CreateTopicCustomFeeParams (
72+ feeCollectorAccountId = "0.0.98" ,
73+ feeCollectorsExempt = True ,
74+ fixedFee = CreateTopicFixedFeeParams (amount = 100 , denominatingTokenId = "0.0.500" ),
75+ )
76+ )
5977 assert fee .amount == 100
6078 assert fee .fee_collector_account_id == AccountId (0 , 0 , 98 )
6179 assert fee .denominating_token_id == TokenId (0 , 0 , 500 )
6280 assert fee .all_collectors_are_exempt is True
6381 with pytest .raises (ValueError , match = "feeCollectorAccountId cannot be empty" ):
64- _build_custom_fee (CreateTopicCustomFeeParams (feeCollectorAccountId = "" , fixedFee = CreateTopicFixedFeeParams (amount = 1 )))
82+ _build_custom_fee (
83+ CreateTopicCustomFeeParams (feeCollectorAccountId = "" , fixedFee = CreateTopicFixedFeeParams (amount = 1 ))
84+ )
6585
6686
6787def test_build_transaction_core_fields ():
68- tx = _build_create_topic_transaction (_params (memo = "m" , adminKey = TEST_KEY , submitKey = TEST_KEY , autoRenewPeriod = 7776000 , autoRenewAccountId = "0.0.98" , feeScheduleKey = TEST_KEY , feeExemptKeys = [TEST_KEY ], customFees = [CreateTopicCustomFeeParams (feeCollectorAccountId = "0.0.98" , fixedFee = CreateTopicFixedFeeParams (amount = 100 ))]))
88+ tx = _build_create_topic_transaction (
89+ _params (
90+ memo = "m" ,
91+ adminKey = TEST_KEY ,
92+ submitKey = TEST_KEY ,
93+ autoRenewPeriod = 7776000 ,
94+ autoRenewAccountId = "0.0.98" ,
95+ feeScheduleKey = TEST_KEY ,
96+ feeExemptKeys = [TEST_KEY ],
97+ customFees = [
98+ CreateTopicCustomFeeParams (
99+ feeCollectorAccountId = "0.0.98" , fixedFee = CreateTopicFixedFeeParams (amount = 100 )
100+ )
101+ ],
102+ )
103+ )
69104 assert tx .memo == "m"
70105 assert getattr (tx .auto_renew_period , "seconds" , tx .auto_renew_period ) == 7776000
71106 assert len (tx .custom_fees ) == 1
@@ -78,7 +113,9 @@ def test_build_transaction_core_fields():
78113 (None , "0.0.98" , "exists" ),
79114 (PrecheckError (status = ResponseCode .INVALID_ACCOUNT_ID ), "0.0.999" , "missing" ),
80115 (
81- ReceiptStatusError (status = ResponseCode .ACCOUNT_DELETED , transaction_id = None , transaction_receipt = MagicMock ()),
116+ ReceiptStatusError (
117+ status = ResponseCode .ACCOUNT_DELETED , transaction_id = None , transaction_receipt = MagicMock ()
118+ ),
82119 "0.0.98" ,
83120 "deleted" ,
84121 ),
@@ -114,6 +151,23 @@ def test_create_topic_rejects_missing_auto_renew(_, mock_get_client, client_mock
114151def test_create_topic_with_all_parameters (_ , mock_get_client , client_mock ):
115152 mock_get_client .return_value = client_mock
116153 with patch .object (TopicCreateTransaction , "execute" , return_value = _success_response (2000 )):
117- result = create_topic (_params (memo = "Full" , adminKey = TEST_KEY , submitKey = TEST_KEY , autoRenewPeriod = 7776000 , autoRenewAccountId = "0.0.98" , feeScheduleKey = TEST_KEY , feeExemptKeys = [TEST_KEY ], customFees = [CreateTopicCustomFeeParams (feeCollectorAccountId = "0.0.98" , feeCollectorsExempt = True , fixedFee = CreateTopicFixedFeeParams (amount = 500 , denominatingTokenId = "0.0.500" ))]))
154+ result = create_topic (
155+ _params (
156+ memo = "Full" ,
157+ adminKey = TEST_KEY ,
158+ submitKey = TEST_KEY ,
159+ autoRenewPeriod = 7776000 ,
160+ autoRenewAccountId = "0.0.98" ,
161+ feeScheduleKey = TEST_KEY ,
162+ feeExemptKeys = [TEST_KEY ],
163+ customFees = [
164+ CreateTopicCustomFeeParams (
165+ feeCollectorAccountId = "0.0.98" ,
166+ feeCollectorsExempt = True ,
167+ fixedFee = CreateTopicFixedFeeParams (amount = 500 , denominatingTokenId = "0.0.500" ),
168+ )
169+ ],
170+ )
171+ )
118172 assert result .status == "SUCCESS"
119173 assert result .topicId == "0.0.2000"
0 commit comments