def test_queue_update(self, m_tags, m_delete, m_update): """ Ensure that queueing an update task uses the proper tags. """ m_task_tags = [m_tags.resource_tag(), m_tags.resource_tag(), m_tags.action_tag()] dist = model.Distributor('rid', 'did', 'd_type_id', {}, False) result = distributor.queue_update(dist, {'m': 'conf'}, {'m': 'delta'}) m_update.apply_async_with_reservation.assert_called_once_with( m_tags.RESOURCE_REPOSITORY_TYPE, dist.repo_id, ['rid', 'did', {'m': 'conf'}, {'m': 'delta'}], tags=m_task_tags) self.assertTrue(result is m_update.apply_async_with_reservation.return_value)
def put(self, request, repo_id, distributor_id): """ Used to update a repo distributor instance. The expected parameters are 'distributor_config', which is a dictionary containing configuration values accepted by the distributor type, and 'delta', which is a dictionary containing other configuration values for the distributor (like the auto_publish flag, for example). Currently, the only supported key in the delta is 'auto_publish', which should have a boolean value. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :param repo_id: id of the repository the distributor is associated with :type repo_id: basestring :param distributor_id: id of the distributor instance to update. :type distributor_id: basestring :raises exceptions.OperationPostponed: dispatch a task """ dist = model.Distributor.objects.get_or_404(repo_id=repo_id, distributor_id=distributor_id) delta = request.body_as_json.get('delta') config = request.body_as_json.get('distributor_config') async_result = dist_controller.queue_update(dist, config, delta) raise exceptions.OperationPostponed(async_result)