mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-12 21:44:21 -06:00
Delete them here too?
This commit is contained in:
@@ -24,6 +24,7 @@ from typing import TYPE_CHECKING
|
|||||||
import pytest
|
import pytest
|
||||||
from django import db
|
from django import db
|
||||||
from django.core.management import CommandError
|
from django.core.management import CommandError
|
||||||
|
from django.test import override_settings
|
||||||
from watchfiles import Change
|
from watchfiles import Change
|
||||||
|
|
||||||
from documents.data_models import ConsumableDocument
|
from documents.data_models import ConsumableDocument
|
||||||
@@ -115,9 +116,6 @@ def mock_supported_extensions(mocker: MockerFixture) -> MagicMock:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# -- TrackedFile Tests --
|
|
||||||
|
|
||||||
|
|
||||||
class TestTrackedFile:
|
class TestTrackedFile:
|
||||||
"""Tests for the TrackedFile dataclass."""
|
"""Tests for the TrackedFile dataclass."""
|
||||||
|
|
||||||
@@ -160,9 +158,6 @@ class TestTrackedFile:
|
|||||||
assert tracked.is_unchanged() is False
|
assert tracked.is_unchanged() is False
|
||||||
|
|
||||||
|
|
||||||
# -- FileStabilityTracker Tests --
|
|
||||||
|
|
||||||
|
|
||||||
class TestFileStabilityTracker:
|
class TestFileStabilityTracker:
|
||||||
"""Tests for the FileStabilityTracker class."""
|
"""Tests for the FileStabilityTracker class."""
|
||||||
|
|
||||||
@@ -306,9 +301,6 @@ class TestFileStabilityTracker:
|
|||||||
assert stability_tracker.pending_count == 1
|
assert stability_tracker.pending_count == 1
|
||||||
|
|
||||||
|
|
||||||
# -- ConsumerFilter Tests --
|
|
||||||
|
|
||||||
|
|
||||||
class TestConsumerFilter:
|
class TestConsumerFilter:
|
||||||
"""Tests for the ConsumerFilter class."""
|
"""Tests for the ConsumerFilter class."""
|
||||||
|
|
||||||
@@ -395,9 +387,6 @@ class TestConsumerFilterDefaults:
|
|||||||
assert filter_obj(Change.added, str(test_file)) is True
|
assert filter_obj(Change.added, str(test_file)) is True
|
||||||
|
|
||||||
|
|
||||||
# -- _consume_file Tests --
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
class TestConsumeFile:
|
class TestConsumeFile:
|
||||||
"""Tests for the _consume_file function."""
|
"""Tests for the _consume_file function."""
|
||||||
@@ -474,9 +463,6 @@ class TestConsumeFile:
|
|||||||
mock_consume_file_delay.delay.assert_not_called()
|
mock_consume_file_delay.delay.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
# -- _tags_from_path Tests --
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
class TestTagsFromPath:
|
class TestTagsFromPath:
|
||||||
"""Tests for the _tags_from_path function."""
|
"""Tests for the _tags_from_path function."""
|
||||||
@@ -519,9 +505,6 @@ class TestTagsFromPath:
|
|||||||
assert len(tag_ids) == 0
|
assert len(tag_ids) == 0
|
||||||
|
|
||||||
|
|
||||||
# -- Command Validation Tests --
|
|
||||||
|
|
||||||
|
|
||||||
class TestCommandValidation:
|
class TestCommandValidation:
|
||||||
"""Tests for command argument validation."""
|
"""Tests for command argument validation."""
|
||||||
|
|
||||||
@@ -550,9 +533,6 @@ class TestCommandValidation:
|
|||||||
cmd.handle(directory=str(sample_pdf), oneshot=True, testing=False)
|
cmd.handle(directory=str(sample_pdf), oneshot=True, testing=False)
|
||||||
|
|
||||||
|
|
||||||
# -- Command Oneshot Tests --
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@pytest.mark.usefixtures("mock_supported_extensions")
|
@pytest.mark.usefixtures("mock_supported_extensions")
|
||||||
class TestCommandOneshot:
|
class TestCommandOneshot:
|
||||||
@@ -621,9 +601,6 @@ class TestCommandOneshot:
|
|||||||
mock_consume_file_delay.delay.assert_not_called()
|
mock_consume_file_delay.delay.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
# -- Command Watch Tests --
|
|
||||||
|
|
||||||
|
|
||||||
class ConsumerThread(Thread):
|
class ConsumerThread(Thread):
|
||||||
"""Thread wrapper for running the consumer command with proper cleanup."""
|
"""Thread wrapper for running the consumer command with proper cleanup."""
|
||||||
|
|
||||||
@@ -652,24 +629,23 @@ class ConsumerThread(Thread):
|
|||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
try:
|
try:
|
||||||
from django.conf import settings
|
with override_settings(
|
||||||
|
SCRATCH_DIR=self.scratch_dir,
|
||||||
# Apply settings directly (thread-safe for reading)
|
CONSUMER_RECURSIVE=self.recursive,
|
||||||
settings.SCRATCH_DIR = self.scratch_dir
|
CONSUMER_SUBDIRS_AS_TAGS=self.subdirs_as_tags,
|
||||||
settings.CONSUMER_RECURSIVE = self.recursive
|
CONSUMER_POLLING_INTERVAL=self.polling_interval,
|
||||||
settings.CONSUMER_SUBDIRS_AS_TAGS = self.subdirs_as_tags
|
CONSUMER_STABILITY_DELAY=self.stability_delay,
|
||||||
settings.CONSUMER_POLLING_INTERVAL = self.polling_interval
|
CONSUMER_IGNORE_PATTERNS=[],
|
||||||
settings.CONSUMER_STABILITY_DELAY = self.stability_delay
|
):
|
||||||
settings.CONSUMER_IGNORE_PATTERNS = []
|
self.cmd.handle(
|
||||||
|
directory=str(self.consumption_dir),
|
||||||
self.cmd.handle(
|
oneshot=False,
|
||||||
directory=str(self.consumption_dir),
|
testing=True,
|
||||||
oneshot=False,
|
)
|
||||||
testing=True,
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.exception = e
|
self.exception = e
|
||||||
finally:
|
finally:
|
||||||
|
Tag.objects.all().delete()
|
||||||
# Close database connections created in this thread
|
# Close database connections created in this thread
|
||||||
db.connections.close_all()
|
db.connections.close_all()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user