File: __init__.py

package info (click to toggle)
python-boto3 1.26.27%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,880 kB
  • sloc: python: 12,629; makefile: 128
file content (75 lines) | stat: -rw-r--r-- 3,461 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
# 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 tests import unittest


class BaseDocsFunctionalTests(unittest.TestCase):
    def assert_contains_lines_in_order(self, lines, contents):
        for line in lines:
            assert line in contents
            beginning = contents.find(line)
            contents = contents[(beginning + len(line)) :]

    def get_class_document_block(self, class_name, contents):
        start_class_document = '.. py:class:: %s' % class_name
        start_index = contents.find(start_class_document)
        assert start_index != -1, 'Class is not found in contents'
        contents = contents[start_index:]
        end_index = contents.find('  .. py:class::', len(start_class_document))
        return contents[:end_index]

    def get_method_document_block(self, method_name, contents):
        start_method_document = '  .. py:method:: %s(' % method_name
        start_index = contents.find(start_method_document)
        assert start_index != -1, 'Method is not found in contents'
        contents = contents[start_index:]
        end_index = contents.find(
            '  .. py:method::', len(start_method_document)
        )
        return contents[:end_index]

    def get_request_syntax_document_block(self, contents):
        start_marker = '**Request Syntax**'
        start_index = contents.find(start_marker)
        assert start_index != -1, 'There is no request syntax section'
        contents = contents[start_index:]
        end_index = contents.find(':type', len(start_marker))
        return contents[:end_index]

    def get_response_syntax_document_block(self, contents):
        start_marker = '**Response Syntax**'
        start_index = contents.find(start_marker)
        assert start_index != -1, 'There is no response syntax section'
        contents = contents[start_index:]
        end_index = contents.find('**Response Structure**', len(start_marker))
        return contents[:end_index]

    def get_request_parameter_document_block(self, param_name, contents):
        start_param_document = ':type %s:' % param_name
        start_index = contents.find(start_param_document)
        assert start_index != -1, 'Param is not found in contents'
        contents = contents[start_index:]
        end_index = contents.find(':type', len(start_param_document))
        return contents[:end_index]

    def get_response_parameter_document_block(self, param_name, contents):
        start_param_document = '**Response Structure**'
        start_index = contents.find(start_param_document)
        assert start_index != -1, 'There is no response structure'

        start_param_document = '- **%s**' % param_name
        start_index = contents.find(start_param_document)
        assert start_index != -1, 'Param is not found in contents'
        contents = contents[start_index:]
        end_index = contents.find('- **', len(start_param_document))
        return contents[:end_index]