File: test_socialmessaging.py

package info (click to toggle)
python-botocore 1.40.68%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 127,976 kB
  • sloc: python: 76,645; xml: 14,037; javascript: 181; makefile: 157
file content (65 lines) | stat: -rw-r--r-- 2,313 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
# Copyright 2024 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
#
# http://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.
import pytest

from botocore import xform_name
from botocore.session import get_session
from botocore.stub import Stubber

_KNOWN_REPLACEMENTS = [
    'whatsapp',
]


def _get_all_xform_operations():
    session = get_session()
    service_model = session.get_service_model("socialmessaging")
    transform_operations = []
    for operation in service_model.operation_names:
        for replacement in _KNOWN_REPLACEMENTS:
            if replacement in operation.lower():
                transform_operations.append((operation, replacement))
    return transform_operations


XFORM_OPERATIONS = _get_all_xform_operations()


@pytest.mark.validates_models
@pytest.mark.parametrize("operation, replacement", XFORM_OPERATIONS)
def test_known_replacements(operation, replacement):
    # Validates that if a replacement shows up in the lowercased version of an
    # operation, we will keep all of those characters together in the final operation
    # name
    assert replacement in xform_name(operation, '_')
    assert replacement in xform_name(operation, '-')


class TestSocialMessaging:
    def test_delete_whatsapp_message_media_aliased(self):
        session = get_session()
        self.client = session.create_client('socialmessaging', 'us-west-2')
        self.stubber = Stubber(self.client)
        self.stubber.activate()
        self.stubber.add_response('delete_whatsapp_message_media', {})
        self.stubber.add_response('delete_whatsapp_message_media', {})

        params = {
            'mediaId': 'foo',
            'originationPhoneNumberId': 'bar',
        }

        self.client.delete_whatsapp_media_message(**params)
        self.client.delete_whatsapp_message_media(**params)

        self.stubber.assert_no_pending_responses()