33from linodecli .documentation .template_data import (
44 Action ,
55 Argument ,
6+ Param ,
67 ResponseAttribute ,
78 Root ,
89)
@@ -28,6 +29,59 @@ def test_data_group(self, mock_cli_with_parsed_template):
2829 assert group .pretty_name == "Test Resource"
2930 assert len (group .actions ) == 4
3031
32+ def test_data_action_view (self , mock_cli_with_parsed_template ):
33+ cli , tmpl_data = mock_cli_with_parsed_template
34+
35+ group = get_first (tmpl_data .groups , lambda v : v .name == "test-resource" )
36+ action = get_first (group .actions , lambda v : v .action [0 ] == "view" )
37+
38+ assert action .command == "test-resource"
39+ assert action .action == ["view" ]
40+
41+ assert "linode-cli test-resource view [-h]" in action .usage
42+ assert "resourceId" in action .usage
43+
44+ assert "Get information about a test resource." == action .summary
45+ assert "Get information about a test resource." == action .description
46+ assert "https://linode.com" == action .api_documentation_url
47+ assert not action .deprecated
48+
49+ assert len (action .argument_sections ) == 0
50+ assert len (action .filterable_attributes ) == 0
51+
52+ self ._validate_resource_parameters (action )
53+ self ._validate_resource_response_attributes (action )
54+
55+ def test_data_action_list (self , mock_cli_with_parsed_template ):
56+ cli , tmpl_data = mock_cli_with_parsed_template
57+
58+ group = get_first (tmpl_data .groups , lambda v : v .name == "test-resource" )
59+ action = get_first (group .actions , lambda v : v .action [0 ] == "list" )
60+
61+ assert action .command == "test-resource"
62+ assert action .action == ["list" , "ls" ]
63+
64+ assert "linode-cli test-resource list [-h]" in action .usage
65+
66+ assert "List test resources." == action .summary
67+ assert "List test resources." == action .description
68+ assert "https://linode.com" == action .api_documentation_url
69+ assert not action .deprecated
70+
71+ assert len (action .argument_sections ) == 0
72+ assert len (action .parameters ) == 0
73+
74+ assert action .filterable_attributes == [
75+ ResponseAttribute (
76+ name = "boolean_field" ,
77+ type = "bool" ,
78+ description = "An arbitrary boolean." ,
79+ example = "true" ,
80+ )
81+ ]
82+
83+ self ._validate_resource_response_attributes (action )
84+
3185 def test_data_action_create (self , mock_cli_with_parsed_template ):
3286 cli , tmpl_data = mock_cli_with_parsed_template
3387
@@ -41,7 +95,7 @@ def test_data_action_create(self, mock_cli_with_parsed_template):
4195 assert "Create a new test resource." == action .summary
4296 assert "Create a new test resource." == action .description
4397 assert "https://linode.com" == action .api_documentation_url
44- assert action .deprecated is None
98+ assert not action .deprecated
4599
46100 assert len (action .parameters ) == 0
47101 assert len (action .samples ) == 0
@@ -129,6 +183,16 @@ def test_data_action_create(self, mock_cli_with_parsed_template):
129183 ),
130184 ]
131185
186+ @staticmethod
187+ def _validate_resource_parameters (action : Action ):
188+ assert action .parameters == [
189+ Param (
190+ name = "resourceId" ,
191+ type = "int" ,
192+ description = "The ID of the resource." ,
193+ )
194+ ]
195+
132196 @staticmethod
133197 def _validate_resource_response_attributes (
134198 action : Action ,
0 commit comments