Esempio n. 1
0
    def test_scanpipe_pipes_outputs_to_xlsx(self):
        project1 = Project.objects.create(name="Analysis")
        codebase_resource = CodebaseResource.objects.create(
            project=project1,
            path="filename.ext",
        )
        DiscoveredPackage.create_for_resource(package_data1, codebase_resource)

        output_file = output.to_xlsx(project=project1)
        self.assertEqual([output_file.name], project1.output_root)
Esempio n. 2
0
    def get(self, request, *args, **kwargs):
        self.object = self.get_object()
        project = self.object
        format = self.kwargs["format"]

        if format == "json":
            return project_results_json_response(project, as_attachment=True)

        elif format == "xlsx":
            output_file = output.to_xlsx(project)
            filename = f"{project.name}_{output_file.name}"
            return FileResponse(output_file.open("rb"), filename=filename)

        raise Http404("Format not supported.")