mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Fix for #131: delete files on document.delete
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from ..models import Document, FileInfo
|
||||
from ..models import FileInfo
|
||||
|
||||
|
||||
class TestAttachment(TestCase):
|
||||
|
20
src/documents/tests/test_document_model.py
Normal file
20
src/documents/tests/test_document_model.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from unittest import mock
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from ..models import Document, Correspondent
|
||||
|
||||
|
||||
class TestDocument(TestCase):
|
||||
|
||||
def test_file_deletion(self):
|
||||
document = Document.objects.create(
|
||||
correspondent=Correspondent.objects.create(name="Test0"),
|
||||
title="Title",
|
||||
content="content",
|
||||
checksum="checksum",
|
||||
)
|
||||
file_path = document.source_path
|
||||
with mock.patch("documents.signals.handlers.os.unlink") as mock_unlink:
|
||||
document.delete()
|
||||
mock_unlink.assert_called_with(file_path)
|
Reference in New Issue
Block a user