def test_render_with_no_data_source(manager): manager.get_template_info.return_value = {'data_source_url': None} template = 'fake' manager.render.return_value = template result = render.delay('some_template') assert template == result.result manager.render.assert_called_with('some_template', data_source={})
def test_render_with_data_source(requests, manager): manager.get_template_info.return_value = { 'data_source_url': 'url', } template = 'fake' manager.render.return_value = template result = render.delay('some_template') assert template == result.result requests.get.assert_called_with('url')
def post(self, request): self.validate(request) template_name = request.data.get('template_name') manager = TemplateManager(settings.RAFEE_REPO_DIR) if not manager.template_exists(template_name): return Response( {'detail': TEMPLATE_NOT_FOUND}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) task = render.delay(template_name) return Response({'task': task.task_id})
def test_task_includes_error(manager): error = ValueError() manager.get_template_info.side_effect = error result = render.delay('some_template') assert error == result.result assert states.FAILURE == result.status