mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-14 00:26:21 +00:00
Feature: document history (audit log UI) (#6388)
This commit is contained in:
@@ -4,6 +4,7 @@ import tempfile
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
from auditlog.context import disable_auditlog
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import DatabaseError
|
||||
@@ -143,7 +144,9 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
# Set a correspondent and save the document
|
||||
document.correspondent = Correspondent.objects.get_or_create(name="test")[0]
|
||||
|
||||
with mock.patch("documents.signals.handlers.Document.objects.filter") as m:
|
||||
with mock.patch(
|
||||
"documents.signals.handlers.Document.objects.filter",
|
||||
) as m, disable_auditlog():
|
||||
m.side_effect = DatabaseError()
|
||||
document.save()
|
||||
|
||||
@@ -557,20 +560,21 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
@override_settings(FILENAME_FORMAT="{title}")
|
||||
@mock.patch("documents.signals.handlers.Document.objects.filter")
|
||||
def test_no_update_without_change(self, m):
|
||||
doc = Document.objects.create(
|
||||
title="document",
|
||||
filename="document.pdf",
|
||||
archive_filename="document.pdf",
|
||||
checksum="A",
|
||||
archive_checksum="B",
|
||||
mime_type="application/pdf",
|
||||
)
|
||||
Path(doc.source_path).touch()
|
||||
Path(doc.archive_path).touch()
|
||||
with disable_auditlog():
|
||||
doc = Document.objects.create(
|
||||
title="document",
|
||||
filename="document.pdf",
|
||||
archive_filename="document.pdf",
|
||||
checksum="A",
|
||||
archive_checksum="B",
|
||||
mime_type="application/pdf",
|
||||
)
|
||||
Path(doc.source_path).touch()
|
||||
Path(doc.archive_path).touch()
|
||||
|
||||
doc.save()
|
||||
doc.save()
|
||||
|
||||
m.assert_not_called()
|
||||
m.assert_not_called()
|
||||
|
||||
|
||||
class TestFileHandlingWithArchive(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
|
Reference in New Issue
Block a user