File scanning: validate wheel digests against pypi.org #199
@ -38,12 +38,12 @@ class FileScanTest(TestCase):
|
|||||||
# A background task should have been created
|
# A background task should have been created
|
||||||
task = Task.objects.created_by(creator=file).first()
|
task = Task.objects.created_by(creator=file).first()
|
||||||
self.assertIsNotNone(task)
|
self.assertIsNotNone(task)
|
||||||
self.assertEqual(task.task_name, 'files.tasks.clamdscan')
|
self.assertEqual(task.task_name, 'files.tasks.scan_file')
|
||||||
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
||||||
|
|
||||||
# Actually run the task as if by background runner
|
# Actually run the task as if by background runner
|
||||||
task_args, task_kwargs = task.params()
|
task_args, task_kwargs = task.params()
|
||||||
files.tasks.clamdscan.task_function(*task_args, **task_kwargs)
|
files.tasks.scan_file.task_function(*task_args, **task_kwargs)
|
||||||
|
|
||||||
file.refresh_from_db()
|
file.refresh_from_db()
|
||||||
self.assertFalse(file.validation.is_ok)
|
self.assertFalse(file.validation.is_ok)
|
||||||
@ -68,12 +68,12 @@ class FileScanTest(TestCase):
|
|||||||
# A background task should have been created
|
# A background task should have been created
|
||||||
task = Task.objects.created_by(creator=file).first()
|
task = Task.objects.created_by(creator=file).first()
|
||||||
self.assertIsNotNone(task)
|
self.assertIsNotNone(task)
|
||||||
self.assertEqual(task.task_name, 'files.tasks.clamdscan')
|
self.assertEqual(task.task_name, 'files.tasks.scan_file')
|
||||||
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
||||||
|
|
||||||
# Actually run the task as if by background runner
|
# Actually run the task as if by background runner
|
||||||
task_args, task_kwargs = task.params()
|
task_args, task_kwargs = task.params()
|
||||||
files.tasks.clamdscan.task_function(*task_args, **task_kwargs)
|
files.tasks.scan_file.task_function(*task_args, **task_kwargs)
|
||||||
|
|
||||||
self.assertFalse(file.validation.is_ok)
|
self.assertFalse(file.validation.is_ok)
|
||||||
file.validation.refresh_from_db()
|
file.validation.refresh_from_db()
|
||||||
@ -95,12 +95,12 @@ class FileScanTest(TestCase):
|
|||||||
# A background task should have been created
|
# A background task should have been created
|
||||||
task = Task.objects.created_by(creator=file).first()
|
task = Task.objects.created_by(creator=file).first()
|
||||||
self.assertIsNotNone(task)
|
self.assertIsNotNone(task)
|
||||||
self.assertEqual(task.task_name, 'files.tasks.clamdscan')
|
self.assertEqual(task.task_name, 'files.tasks.scan_file')
|
||||||
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
|
||||||
|
|
||||||
# Actually run the task as if by background runner
|
# Actually run the task as if by background runner
|
||||||
task_args, task_kwargs = task.params()
|
task_args, task_kwargs = task.params()
|
||||||
files.tasks.clamdscan.task_function(*task_args, **task_kwargs)
|
files.tasks.scan_file.task_function(*task_args, **task_kwargs)
|
||||||
|
|
||||||
file.refresh_from_db()
|
file.refresh_from_db()
|
||||||
self.assertTrue(file.validation.is_ok)
|
self.assertTrue(file.validation.is_ok)
|
||||||
|
Loading…
Reference in New Issue
Block a user