File: test_collection.py

package info (click to toggle)
python-boto3 1.37.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,868 kB
  • sloc: python: 13,931; javascript: 192; makefile: 170
file content (132 lines) | stat: -rw-r--r-- 5,894 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# https://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from boto3.docs.collection import CollectionDocumenter
from tests.unit.docs import BaseDocsTest


class TestCollectionDocumenter(BaseDocsTest):
    def test_document_collections(self):
        collection_documenter = CollectionDocumenter(
            self.resource, self.root_services_path
        )
        collection_documenter.document_collections(self.doc_structure)
        self.assert_contains_lines_in_order(
            [
                '-----------\nCollections\n-----------',
                'Collections provide an interface to iterate over and ',
                'manipulate groups of resources. ',
                'For more information about collections refer to the ',
            ]
        )
        self.assert_contains_lines_in_order(
            [
                'samples',
                '.. py:attribute:: MyService.ServiceResource.samples',
                '  A collection of Sample resources.'
                'A Sample Collection will include all resources by default, '
                'and extreme caution should be taken when performing actions '
                'on all resources.',
                '  .. py:method:: all()',
                (
                    '    Creates an iterable of all Sample resources in the '
                    'collection.'
                ),
                '    **Request Syntax**',
                '    ::',
                '      sample_iterator = myservice.samples.all()',
                '    :rtype: list(:py:class:`myservice.Sample`)',
                '    :returns: A list of Sample resources',
                '  .. py:method:: filter(**kwargs)',
                (
                    '    Creates an iterable of all Sample resources in '
                    'the collection filtered by kwargs passed to method. '
                    'A Sample collection will include all resources by default '
                    'if no filters are provided, and extreme caution should be '
                    'taken when performing actions on all resources'
                ),
                '    **Request Syntax**',
                '    ::',
                '      sample_iterator = myservice.samples.filter(',
                "          Foo='string',",
                "          Bar='string'",
                '      )',
                '    :type Foo: string',
                '    :param Foo: Documents Foo',
                '    :type Bar: string',
                '    :param Bar: Documents Bar',
                '    :rtype: list(:py:class:`myservice.Sample`)',
                '    :returns: A list of Sample resources',
                '  .. py:method:: limit(**kwargs)',
                (
                    '    Creates an iterable up to a specified amount of '
                    'Sample resources in the collection.'
                ),
                '    **Request Syntax**',
                '    ::',
                '      sample_iterator = myservice.samples.limit(',
                '          count=123',
                '      )',
                '    :type count: integer',
                (
                    '    :param count: The limit to the number of resources '
                    'in the iterable.'
                ),
                '    :rtype: list(:py:class:`myservice.Sample`)',
                '    :returns: A list of Sample resources',
                '  .. py:method:: operate(**kwargs)',
                '    **Request Syntax**',
                '      response = myservice.samples.operate(',
                "          Foo='string',",
                "          Bar='string'",
                '      )',
                '    :type Foo: string',
                '    :param Foo: Documents Foo',
                '    :type Bar: string',
                '    :param Bar: Documents Bar',
                '    :rtype: dict',
                '    :returns: ',
                '      **Response Syntax**',
                '      ::',
                '        {',
                "            'Foo': 'string',",
                "            'Bar': 'string'",
                '        }',
                '      **Response Structure**',
                '      - *(dict) --* ',
                '        - **Foo** *(string) --* Documents Foo',
                '        - **Bar** *(string) --* Documents Bar',
                '  .. py:method:: page_size(**kwargs)',
                (
                    '    Creates an iterable of all Sample resources in the '
                    'collection, but limits the number of items returned by '
                    'each service call by the specified amount.'
                ),
                '    **Request Syntax**',
                '    ::',
                '',
                '      sample_iterator = myservice.samples.page_size(',
                '          count=123',
                '      )',
                '    :type count: integer',
                (
                    '    :param count: The number of items returned by '
                    'each service call'
                ),
                '    :rtype: list(:py:class:`myservice.Sample`)',
                '    :returns: A list of Sample resources',
                '    ',
            ],
            self.get_nested_service_contents(
                'myservice', 'service-resource', 'samples'
            ),
        )