python-botocore/tests/functional/test_sagemaker.py

40 lines
1.3 KiB
Python
Raw Permalink Normal View History

2018-08-16 08:01:54 +02:00
from botocore.stub import Stubber
from tests import BaseSessionTest
class TestSagemaker(BaseSessionTest):
def setUp(self):
2022-05-26 00:10:07 +02:00
super().setUp()
2018-08-16 08:01:54 +02:00
self.region = 'us-west-2'
2022-05-26 00:10:07 +02:00
self.client = self.session.create_client('sagemaker', self.region)
2018-08-16 08:01:54 +02:00
self.stubber = Stubber(self.client)
self.stubber.activate()
self.hook_calls = []
def _hook(self, **kwargs):
self.hook_calls.append(kwargs['event_name'])
def tearDown(self):
2022-12-12 17:14:19 +01:00
super().tearDown()
2018-08-16 08:01:54 +02:00
self.stubber.deactivate()
def test_event_with_old_prefix(self):
self.client.meta.events.register(
2022-05-26 00:10:07 +02:00
'provide-client-params.sagemaker.ListEndpoints', self._hook
2018-08-16 08:01:54 +02:00
)
self.stubber.add_response('list_endpoints', {'Endpoints': []})
self.client.list_endpoints()
2022-05-26 00:10:07 +02:00
self.assertEqual(
self.hook_calls, ['provide-client-params.sagemaker.ListEndpoints']
)
2018-08-16 08:01:54 +02:00
def test_event_with_new_prefix(self):
self.client.meta.events.register(
2022-05-26 00:10:07 +02:00
'provide-client-params.api.sagemaker.ListEndpoints', self._hook
2018-08-16 08:01:54 +02:00
)
self.stubber.add_response('list_endpoints', {'Endpoints': []})
self.client.list_endpoints()
2022-05-26 00:10:07 +02:00
self.assertEqual(
self.hook_calls, ['provide-client-params.sagemaker.ListEndpoints']
)