Skip to content

Commit 0c2831e

Browse files
committed
chore: add basic unit test for deprecated aliases
Signed-off-by: exploreriii <[email protected]>
1 parent d64b811 commit 0c2831e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/unit/test_deprecated.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import pytest
2+
from unittest.mock import MagicMock
3+
4+
from hiero_sdk_python.tokens.nft_id import NftId
5+
from hiero_sdk_python.tokens.token_info import TokenInfo
6+
from hiero_sdk_python.transaction.transaction_receipt import TransactionReceipt
7+
from hiero_sdk_python.tokens.token_id import TokenId
8+
9+
def test_nftid_deprecated_alias_access():
10+
token = TokenId.from_string("0.0.123")
11+
nft = NftId(token_id=token, serial_number=7)
12+
13+
# serialNumber -> serial_number
14+
with pytest.warns(FutureWarning) as record_serial:
15+
got = nft.serialNumber
16+
assert got == 7
17+
assert "serialNumber" in str(record_serial[0].message)
18+
19+
# tokenId -> token_id
20+
with pytest.warns(FutureWarning) as record_tokenid:
21+
got = nft.tokenId
22+
assert got is token
23+
assert "tokenId" in str(record_tokenid[0].message)
24+
25+
26+
def test_tokeninfo_deprecated_alias_access():
27+
token = TokenId.from_string("0.0.456")
28+
info = TokenInfo(token_id=token, total_supply=1000, is_deleted=True)
29+
30+
# totalSupply -> total_supply
31+
with pytest.warns(FutureWarning) as record_supply:
32+
got = info.totalSupply
33+
assert got == 1000
34+
assert "totalSupply" in str(record_supply[0].message)
35+
36+
# isDeleted -> is_deleted
37+
with pytest.warns(FutureWarning) as record_delete:
38+
got = info.isDeleted
39+
assert got is True
40+
assert "isDeleted" in str(record_delete[0].message)
41+
42+
43+
def test_transactionreceipt_deprecated_alias_access():
44+
proto = MagicMock()
45+
proto.status = "OK"
46+
proto.HasField.return_value = False
47+
proto.serialNumbers = [1, 2, 3]
48+
49+
tr = TransactionReceipt(receipt_proto=proto)
50+
51+
# tokenId -> token_id
52+
with pytest.warns(FutureWarning) as record_token:
53+
got = tr.tokenId
54+
assert got is None
55+
assert "tokenId" in str(record_token[0].message)
56+
57+
# topicId -> topic_id
58+
with pytest.warns(FutureWarning) as record_topic:
59+
got = tr.topicId
60+
assert got is None
61+
assert "topicId" in str(record_topic[0].message)
62+
63+
# accountId -> account_id
64+
with pytest.warns(FutureWarning) as record_acc:
65+
acc = tr.accountId
66+
assert acc is None
67+
assert "accountId" in str(record_acc[0].message)

0 commit comments

Comments
 (0)