mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-24 10:20:31 +00:00
Test modules in paperless, paperless_mail and documents imported filesystem assertions, the migration test base, the retry helper and the streaming-response reader out of documents/tests/utils.py, which kept each app's tests coupled to another app's test package. They now live in paperless_testing, and the progress manager fake is renamed FakeProgressManager and now subclasses the real ProgressManager, overriding only the transport, so the payload it records is built by the production code. The twenty places that patched documents.tasks.ProgressManager by hand now use a fake_progress_manager fixture.
32 lines
902 B
Python
32 lines
902 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from documents.plugins.helpers import ProgressManager
|
|
|
|
if TYPE_CHECKING:
|
|
from documents.plugins.helpers import WebsocketPayload
|
|
|
|
|
|
class FakeProgressManager(ProgressManager):
|
|
"""
|
|
The real ProgressManager with the channel layer cut out: send_progress still
|
|
builds the payload, so it cannot drift, and the payloads are recorded instead
|
|
of being sent to Redis.
|
|
|
|
Use it through the `fake_progress_manager` fixture, or construct it directly.
|
|
"""
|
|
|
|
def __init__(self, filename: str | None = None, task_id: str | None = None) -> None:
|
|
super().__init__(filename, task_id)
|
|
self.payloads: list[WebsocketPayload] = []
|
|
|
|
def open(self) -> None:
|
|
pass
|
|
|
|
def close(self) -> None:
|
|
pass
|
|
|
|
def send(self, payload: WebsocketPayload) -> None:
|
|
self.payloads.append(payload)
|