1# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"). You 4# may not use this file except in compliance with the License. A copy of 5# the License is located at 6# 7# https://aws.amazon.com/apache2.0/ 8# 9# or in the "license" file accompanying this file. This file is 10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 11# ANY KIND, either express or implied. See the License for the specific 12# language governing permissions and limitations under the License. 13from tests.unit.docs import BaseDocsTest 14 15from boto3.docs.action import ActionDocumenter 16 17 18class TestActionDocumenter(BaseDocsTest): 19 def test_document_service_resource_actions(self): 20 action_documenter = ActionDocumenter(self.resource) 21 action_documenter.document_actions(self.doc_structure) 22 self.assert_contains_lines_in_order([ 23 '.. py:method:: sample_operation(**kwargs)', 24 ' **Request Syntax**', 25 ' ::', 26 ' response = myservice.sample_operation(', 27 ' Foo=\'string\',', 28 ' Bar=\'string\'', 29 ' )', 30 ' :type Foo: string', 31 ' :param Foo: Documents Foo', 32 ' :type Bar: string', 33 ' :param Bar: Documents Bar', 34 ' :rtype: dict', 35 ' :returns:', 36 ' **Response Syntax**', 37 ' ::', 38 ' {', 39 ' \'Foo\': \'string\',', 40 ' \'Bar\': \'string\'', 41 ' }', 42 ' **Response Structure**', 43 ' - *(dict) --*', 44 ' - **Foo** *(string) --* Documents Foo', 45 ' - **Bar** *(string) --* Documents Bar' 46 ]) 47 48 def test_document_nonservice_resource_actions(self): 49 subresource = self.resource.Sample('mysample') 50 action_documenter = ActionDocumenter(subresource) 51 action_documenter.document_actions(self.doc_structure) 52 self.assert_contains_lines_in_order([ 53 '.. py:method:: load()', 54 (' Calls :py:meth:`MyService.Client.sample_operation` to update ' 55 'the attributes of the Sample resource'), 56 ' **Request Syntax** ', 57 ' ::', 58 ' sample.load()', 59 ' :returns: None', 60 '.. py:method:: operate(**kwargs)', 61 ' **Request Syntax** ', 62 ' ::', 63 ' response = sample.operate(', 64 " Bar='string'", 65 ' )', 66 ' :type Bar: string', 67 ' :param Bar: Documents Bar', 68 ' :rtype: dict', 69 ' :returns: ', 70 ' ', 71 ' **Response Syntax** ', 72 ' ::', 73 ' {', 74 " 'Foo': 'string',", 75 " 'Bar': 'string'", 76 ' }', 77 ' **Response Structure** ', 78 ' - *(dict) --* ', 79 ' - **Foo** *(string) --* Documents Foo', 80 ' - **Bar** *(string) --* Documents Bar', 81 '.. py:method:: reload()', 82 (' Calls :py:meth:`MyService.Client.sample_operation` to update ' 83 'the attributes of the Sample resource'), 84 ' **Request Syntax** ', 85 ' ::', 86 ' sample.reload()', 87 ' :returns: None' 88 ]) 89