def test_share_delete_metadata(self): fake_keys = ["aim", "project", "deadline"] api.share_delete_metadata(self.request, self.id, fake_keys) self.manilaclient.shares.delete_metadata.assert_called_once_with( self.id, fake_keys)
def handle(self, request, data): share_id = self.initial['share_id'] try: share = manila.share_get(self.request, share_id) set_dict, unset_list = utils.parse_str_meta(data['metadata']) if set_dict: manila.share_set_metadata(request, share, set_dict) if unset_list: manila.share_delete_metadata(request, share, unset_list) message = _('Updating share metadata "%s"') % share.name messages.success(request, message) return True except ValidationError as e: self.api_error(e.messages[0]) return False except Exception: redirect = reverse("horizon:project:shares:index") exceptions.handle(request, _('Unable to update share metadata.'), redirect=redirect)