@@ -3668,3 +3668,54 @@ def test_is_subnet_active(subtensor, mocker, query_return, expected):
36683668 )
36693669
36703670 assert result == expected
3671+
3672+
3673+ # `geg_l_subnet_info` tests
3674+ def test_get_subnet_info_success (mocker , subtensor ):
3675+ """Test get_subnet_info returns correct data when subnet information is found."""
3676+ # Prep
3677+ netuid = mocker .Mock ()
3678+ block = mocker .Mock ()
3679+
3680+ mocker .patch .object (subtensor , "query_runtime_api" )
3681+ mocker .patch .object (
3682+ subtensor_module .SubnetInfo ,
3683+ "from_dict" ,
3684+ )
3685+
3686+ # Call
3687+ result = subtensor .get_subnet_info (netuid = netuid , block = block )
3688+
3689+ # Asserts
3690+ subtensor .query_runtime_api .assert_called_once_with (
3691+ runtime_api = "SubnetInfoRuntimeApi" ,
3692+ method = "get_subnet_info_v2" ,
3693+ params = [netuid ],
3694+ block = block ,
3695+ )
3696+ subtensor_module .SubnetInfo .from_dict .assert_called_once_with (
3697+ subtensor .query_runtime_api .return_value ,
3698+ )
3699+ assert result == subtensor_module .SubnetInfo .from_dict .return_value
3700+
3701+
3702+ def test_get_subnet_info_no_data (mocker , subtensor ):
3703+ """Test get_subnet_info returns None."""
3704+ # Prep
3705+ netuid = mocker .Mock ()
3706+ block = mocker .Mock ()
3707+ mocker .patch .object (subtensor_module .SubnetInfo , "from_dict" )
3708+ mocker .patch .object (subtensor , "query_runtime_api" , return_value = None )
3709+
3710+ # Call
3711+ result = subtensor .get_subnet_info (netuid = netuid , block = block )
3712+
3713+ # Asserts
3714+ subtensor .query_runtime_api .assert_called_once_with (
3715+ runtime_api = "SubnetInfoRuntimeApi" ,
3716+ method = "get_subnet_info_v2" ,
3717+ params = [netuid ],
3718+ block = block ,
3719+ )
3720+ subtensor_module .SubnetInfo .from_dict .assert_not_called ()
3721+ assert result is None
0 commit comments