def test_get_single_waiter_config(self): single_waiter = { 'description': 'Waiter description', 'operation': 'HeadBucket', 'delay': 5, 'maxAttempts': 20, 'acceptors': [ { 'state': 'success', 'matcher': 'status', 'expected': 200 }, { 'state': 'retry', 'matcher': 'status', 'expected': 404 }, ], } waiters = { 'version': 2, 'waiters': { 'BucketExists': single_waiter, } } model = WaiterModel(waiters) config = model.get_waiter('BucketExists') self.assertEqual(config.operation, 'HeadBucket')
def test_get_waiter_does_not_exist(self): waiters = { 'version': 2, 'waiters': {} } model = WaiterModel(waiters) with self.assertRaises(ValueError): model.get_waiter('UnknownWaiter')
def test_unsupported_waiter_version(self): waiters = { 'version': 1, 'waiters': {} } with self.assertRaises(WaiterConfigError): WaiterModel(waiters)
def setUp(self): super(TestWaiterDocumenter, self).setUp() self.add_shape_to_params('Biz', 'String') self.setup_client() waiter_model = WaiterModel(self.waiter_json_model) self.waiter_documenter = WaiterDocumenter( client=self.client, service_waiter_model=waiter_model)
def get_waiter_model(self, service, api_version=None): """Get the waiter model for the service.""" with mock.patch('ibm_botocore.loaders.Loader.list_available_services', return_value=[service]): return WaiterModel( self.loader.load_service_model(service, type_name='waiters-2', api_version=api_version))
def test_wont_load_missing_version_in_config(self): # We only load waiter configs if we know for sure that we're # loading version 2 of the format. waiters = { # Missing the 'version' key. 'waiters': {} } with self.assertRaises(WaiterConfigError): WaiterModel(waiters)
def test_waiter_names(self): waiters = { 'version': 2, 'waiters': { 'BarWaiter': {}, 'FooWaiter': {}, } } self.assertEqual(WaiterModel(waiters).waiter_names, ['BarWaiter', 'FooWaiter'])
def setUp(self): self.waiter_config = { 'version': 2, 'waiters': { 'WaiterName': { 'operation': 'Foo', 'delay': 1, 'maxAttempts': 1, 'acceptors': [], }, }, } self.waiter_model = WaiterModel(self.waiter_config) self.service_json_model = { 'metadata': { 'serviceFullName': 'Amazon MyService' }, 'operations': { 'Foo': { 'name': 'Foo', 'input': { 'shape': 'FooInputOutput' }, 'output': { 'shape': 'FooInputOutput' } } }, 'shapes': { 'FooInputOutput': { 'type': 'structure', 'members': { 'bar': { 'shape': 'String', 'documentation': 'Documents bar' } } }, 'String': { 'type': 'string' } } } self.service_model = ServiceModel(self.service_json_model, 'myservice') self.client = mock.Mock() self.client.meta.service_model = self.service_model
def test_waiter_version(self): self.assertEqual(WaiterModel({'version': 2, 'waiters': {}}).version, 2)