|
40 | 40 | from scanpipe.pipes.input import copy_input
|
41 | 41 | from scanpipe.pipes.input import copy_inputs
|
42 | 42 | from scanpipe.tests import dependency_data1
|
| 43 | +from scanpipe.tests import make_project |
43 | 44 | from scanpipe.tests import make_resource_file
|
44 | 45 | from scanpipe.tests import mocked_now
|
45 | 46 | from scanpipe.tests import package_data1
|
@@ -305,6 +306,25 @@ def test_scanpipe_pipes_make_codebase_resource(self):
|
305 | 306 | self.assertEqual(1, p1.codebaseresources.count())
|
306 | 307 | self.assertEqual(0, p1.projectmessages.count())
|
307 | 308 |
|
| 309 | + @mock.patch("scanpipe.pipes.scancode.get_resource_info") |
| 310 | + def test_scanpipe_pipes_make_codebase_resource_permission_denied( |
| 311 | + self, mock_get_info |
| 312 | + ): |
| 313 | + project = make_project() |
| 314 | + mock_get_info.side_effect = PermissionError("Permission denied") |
| 315 | + resource_location = str(project.codebase_path / "notice.NOTICE") |
| 316 | + |
| 317 | + resource = pipes.make_codebase_resource(project, location=resource_location) |
| 318 | + self.assertTrue(resource.pk) |
| 319 | + self.assertEqual(flag.RESOURCE_READ_ERROR, resource.status) |
| 320 | + self.assertEqual("notice.NOTICE", str(resource.path)) |
| 321 | + |
| 322 | + error = project.projectmessages.get() |
| 323 | + self.assertEqual("error", error.severity) |
| 324 | + self.assertEqual("Permission denied", error.description) |
| 325 | + self.assertEqual("CodebaseResource", error.model) |
| 326 | + self.assertEqual({"resource_path": "notice.NOTICE"}, error.details) |
| 327 | + |
308 | 328 | def test_scanpipe_add_resource_to_package(self):
|
309 | 329 | project1 = Project.objects.create(name="Analysis")
|
310 | 330 | resource1 = make_resource_file(project=project1, path="filename.ext")
|
|
0 commit comments