def test_delete_not_found(self, mockclient): class ZaqarClientPlugin(client_plugin.ClientPlugin): def _create(self): return mockclient() mock_def = mock.Mock(spec=rsrc_defn.ResourceDefinition) mock_stack = mock.Mock() mock_stack.db_resource_get.return_value = None mock_stack.has_cache_data.return_value = False mockplugin = ZaqarClientPlugin(self.ctx) mock_stack.clients = mock.Mock() mock_stack.clients.client_plugin.return_value = mockplugin mockplugin.is_not_found = mock.Mock() mockplugin.is_not_found.return_value = True zaqar_q = mock.Mock() zaqar_q.delete.side_effect = ResourceNotFound() mockclient.return_value.queue.return_value = zaqar_q zplugin = queue.ZaqarQueue("test_delete_not_found", mock_def, mock_stack) zplugin.resource_id = "test_delete_not_found" zplugin.handle_delete() mock_stack.clients.client_plugin.assert_called_once_with('zaqar') mockplugin.is_not_found.assert_called_once_with( zaqar_q.delete.side_effect) mockclient.return_value.queue.assert_called_once_with( "test_delete_not_found", auto_create=False)
def test_delete_not_found(self, mock_client, mock_plugin): t = template_format.parse(wp_template) self.parse_stack(t) subscr = self.stack['MySubscription'] subscr_id = "58138648c1e2eb7355d62137" self.m.StubOutWithMock(subscr, 'client') subscr.client().MultipleTimes().AndReturn(self.fc) fake_subscr = FakeSubscription(subscr.properties['queue_name'], subscr_id) self.m.StubOutWithMock(self.fc, 'subscription') self.fc.subscription(subscr.properties['queue_name'], options={'key1': 'value1'}, subscriber=u'mailto:[email protected]', ttl=3600).AndReturn(fake_subscr) self.fc.subscription(subscr.properties['queue_name'], id=subscr_id, auto_create=False).AndRaise(ResourceNotFound()) self.m.ReplayAll() scheduler.TaskRunner(subscr.create)() scheduler.TaskRunner(subscr.delete)() self.m.VerifyAll()
def test_delete_not_found(self, mockclient): class ZaqarClientPlugin(client_plugin.ClientPlugin): def _create(self): return mockclient() mock_def = mock.Mock(spec=rsrc_defn.ResourceDefinition) mock_def.resource_type = 'OS::Zaqar::Queue' props = mock.Mock() props.props = {} mock_def.properties.return_value = props stack = utils.parse_stack(template_format.parse(wp_template)) self.patchobject(stack, 'db_resource_get', return_value=None) mockplugin = ZaqarClientPlugin(self.ctx) clients = self.patchobject(stack, 'clients') clients.client_plugin.return_value = mockplugin mockplugin.is_not_found = mock.Mock() mockplugin.is_not_found.return_value = True zaqar_q = mock.Mock() zaqar_q.delete.side_effect = ResourceNotFound() mockclient.return_value.queue.return_value = zaqar_q zplugin = queue.ZaqarQueue("test_delete_not_found", mock_def, stack) zplugin.resource_id = "test_delete_not_found" zplugin.handle_delete() clients.client_plugin.assert_called_once_with('zaqar') mockplugin.is_not_found.assert_called_once_with( zaqar_q.delete.side_effect) mockclient.return_value.queue.assert_called_once_with( "test_delete_not_found", auto_create=False)
def test_delete_not_found(self, mock_client): subscr = self.subscr subscr_id = "58138648c1e2eb7355d62137" fake_subscr = FakeSubscription(subscr.properties['queue_name'], subscr_id) self.m.StubOutWithMock(self.fc, 'subscription') self.fc.subscription(subscr.properties['queue_name'], options=self.options, subscriber=self.subscriber, ttl=220367260800).AndReturn(fake_subscr) self.fc.subscription(subscr.properties['queue_name'], id=subscr_id, auto_create=False).AndRaise(ResourceNotFound()) self.m.ReplayAll() scheduler.TaskRunner(subscr.create)() scheduler.TaskRunner(subscr.delete)() self.m.VerifyAll()