Chore(mypy): Annotate None returns for typing improvements (#11213)

This commit is contained in:
Sebastian Steinbeißer
2026-02-02 17:44:12 +01:00
committed by GitHub
parent a9c0b06e28
commit 3b5ffbf9fa
113 changed files with 1598 additions and 1510 deletions

View File

@@ -10,7 +10,7 @@ class PaperlessConfig(AppConfig):
verbose_name = _("Paperless")
def ready(self):
def ready(self) -> None:
from django.contrib.auth.signals import user_login_failed
user_login_failed.connect(handle_failed_login)

View File

@@ -14,7 +14,7 @@ logger = logging.getLogger("paperless.auth")
class AutoLoginMiddleware(MiddlewareMixin):
def process_request(self, request: HttpRequest):
def process_request(self, request: HttpRequest) -> None:
# Dont use auto-login with token request
if request.path.startswith("/api/token/") and request.method == "POST":
return None

View File

@@ -34,20 +34,20 @@ class StatusConsumer(WebsocketConsumer):
)
raise AcceptConnection
def disconnect(self, close_code):
def disconnect(self, close_code) -> None:
async_to_sync(self.channel_layer.group_discard)(
"status_updates",
self.channel_name,
)
def status_update(self, event):
def status_update(self, event) -> None:
if not self._authenticated():
self.close()
else:
if self._can_view(event["data"]):
self.send(json.dumps(event))
def documents_deleted(self, event):
def documents_deleted(self, event) -> None:
if not self._authenticated():
self.close()
else:

View File

@@ -13,5 +13,5 @@ def custom_get_table_cache_key(db_alias, table):
return PREFIX + get_table_cache_key(db_alias, table)
def invalidate_db_cache():
def invalidate_db_cache() -> None:
return cachalot_invalidate(cache_alias="read-cache")

View File

@@ -18,7 +18,7 @@ from paperless.adapter import DrfTokenStrategy
class TestCustomAccountAdapter(TestCase):
def test_is_open_for_signup(self):
def test_is_open_for_signup(self) -> None:
adapter = get_adapter()
# With no accounts, signups should be allowed
@@ -34,7 +34,7 @@ class TestCustomAccountAdapter(TestCase):
settings.ACCOUNT_ALLOW_SIGNUPS = False
self.assertFalse(adapter.is_open_for_signup(None))
def test_is_safe_url(self):
def test_is_safe_url(self) -> None:
request = HttpRequest()
request.get_host = mock.Mock(return_value="example.com")
with context.request_context(request):
@@ -59,7 +59,7 @@ class TestCustomAccountAdapter(TestCase):
self.assertFalse(adapter.is_safe_url(url))
@mock.patch("allauth.core.internal.ratelimit.consume", return_value=True)
def test_pre_authenticate(self, mock_consume):
def test_pre_authenticate(self, mock_consume) -> None:
adapter = get_adapter()
request = HttpRequest()
request.get_host = mock.Mock(return_value="example.com")
@@ -71,7 +71,7 @@ class TestCustomAccountAdapter(TestCase):
with self.assertRaises(ValidationError):
adapter.pre_authenticate(request)
def test_get_reset_password_from_key_url(self):
def test_get_reset_password_from_key_url(self) -> None:
request = HttpRequest()
request.get_host = mock.Mock(return_value="foo.org")
with context.request_context(request):
@@ -93,7 +93,7 @@ class TestCustomAccountAdapter(TestCase):
)
@override_settings(ACCOUNT_DEFAULT_GROUPS=["group1", "group2"])
def test_save_user_adds_groups(self):
def test_save_user_adds_groups(self) -> None:
Group.objects.create(name="group1")
user = User.objects.create_user("testuser")
adapter = get_adapter()
@@ -110,7 +110,7 @@ class TestCustomAccountAdapter(TestCase):
self.assertTrue(user.groups.filter(name="group1").exists())
self.assertFalse(user.groups.filter(name="group2").exists())
def test_fresh_install_save_creates_superuser(self):
def test_fresh_install_save_creates_superuser(self) -> None:
adapter = get_adapter()
form = mock.Mock(
cleaned_data={
@@ -133,7 +133,7 @@ class TestCustomAccountAdapter(TestCase):
class TestCustomSocialAccountAdapter(TestCase):
def test_is_open_for_signup(self):
def test_is_open_for_signup(self) -> None:
adapter = get_social_adapter()
# Test when SOCIALACCOUNT_ALLOW_SIGNUPS is True
@@ -144,7 +144,7 @@ class TestCustomSocialAccountAdapter(TestCase):
settings.SOCIALACCOUNT_ALLOW_SIGNUPS = False
self.assertFalse(adapter.is_open_for_signup(None, None))
def test_get_connect_redirect_url(self):
def test_get_connect_redirect_url(self) -> None:
adapter = get_social_adapter()
request = None
socialaccount = None
@@ -157,7 +157,7 @@ class TestCustomSocialAccountAdapter(TestCase):
)
@override_settings(SOCIAL_ACCOUNT_DEFAULT_GROUPS=["group1", "group2"])
def test_save_user_adds_groups(self):
def test_save_user_adds_groups(self) -> None:
Group.objects.create(name="group1")
adapter = get_social_adapter()
request = HttpRequest()
@@ -172,7 +172,7 @@ class TestCustomSocialAccountAdapter(TestCase):
self.assertTrue(user.groups.filter(name="group1").exists())
self.assertFalse(user.groups.filter(name="group2").exists())
def test_error_logged_on_authentication_error(self):
def test_error_logged_on_authentication_error(self) -> None:
adapter = get_social_adapter()
request = HttpRequest()
with self.assertLogs("paperless.auth", level="INFO") as log_cm:
@@ -188,7 +188,7 @@ class TestCustomSocialAccountAdapter(TestCase):
class TestDrfTokenStrategy(TestCase):
def test_create_access_token_creates_new_token(self):
def test_create_access_token_creates_new_token(self) -> None:
"""
GIVEN:
- A user with no existing DRF token
@@ -213,7 +213,7 @@ class TestDrfTokenStrategy(TestCase):
token = Token.objects.get(user=user)
self.assertEqual(token_key, token.key)
def test_create_access_token_returns_existing_token(self):
def test_create_access_token_returns_existing_token(self) -> None:
"""
GIVEN:
- A user with an existing DRF token
@@ -238,7 +238,7 @@ class TestDrfTokenStrategy(TestCase):
# Verify only one token exists (no duplicate created)
self.assertEqual(Token.objects.filter(user=user).count(), 1)
def test_create_access_token_returns_none_for_unauthenticated_user(self):
def test_create_access_token_returns_none_for_unauthenticated_user(self) -> None:
"""
GIVEN:
- An unauthenticated request

View File

@@ -15,14 +15,14 @@ from paperless.checks import settings_values_check
class TestChecks(DirectoriesMixin, TestCase):
def test_binaries(self):
def test_binaries(self) -> None:
self.assertEqual(binaries_check(None), [])
@override_settings(CONVERT_BINARY="uuuhh")
def test_binaries_fail(self):
def test_binaries_fail(self) -> None:
self.assertEqual(len(binaries_check(None)), 1)
def test_paths_check(self):
def test_paths_check(self) -> None:
self.assertEqual(paths_check(None), [])
@override_settings(
@@ -30,14 +30,14 @@ class TestChecks(DirectoriesMixin, TestCase):
DATA_DIR=Path("whatever"),
CONSUMPTION_DIR=Path("idontcare"),
)
def test_paths_check_dont_exist(self):
def test_paths_check_dont_exist(self) -> None:
msgs = paths_check(None)
self.assertEqual(len(msgs), 3, str(msgs))
for msg in msgs:
self.assertTrue(msg.msg.endswith("is set but doesn't exist."))
def test_paths_check_no_access(self):
def test_paths_check_no_access(self) -> None:
Path(self.dirs.data_dir).chmod(0o000)
Path(self.dirs.media_dir).chmod(0o000)
Path(self.dirs.consumption_dir).chmod(0o000)
@@ -53,16 +53,16 @@ class TestChecks(DirectoriesMixin, TestCase):
self.assertTrue(msg.msg.endswith("is not writeable"))
@override_settings(DEBUG=False)
def test_debug_disabled(self):
def test_debug_disabled(self) -> None:
self.assertEqual(debug_mode_check(None), [])
@override_settings(DEBUG=True)
def test_debug_enabled(self):
def test_debug_enabled(self) -> None:
self.assertEqual(len(debug_mode_check(None)), 1)
class TestSettingsChecksAgainstDefaults(DirectoriesMixin, TestCase):
def test_all_valid(self):
def test_all_valid(self) -> None:
"""
GIVEN:
- Default settings
@@ -77,7 +77,7 @@ class TestSettingsChecksAgainstDefaults(DirectoriesMixin, TestCase):
class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
@override_settings(OCR_OUTPUT_TYPE="notapdf")
def test_invalid_output_type(self):
def test_invalid_output_type(self) -> None:
"""
GIVEN:
- Default settings
@@ -95,7 +95,7 @@ class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn('OCR output type "notapdf"', msg.msg)
@override_settings(OCR_MODE="makeitso")
def test_invalid_ocr_type(self):
def test_invalid_ocr_type(self) -> None:
"""
GIVEN:
- Default settings
@@ -113,7 +113,7 @@ class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn('OCR output mode "makeitso"', msg.msg)
@override_settings(OCR_MODE="skip_noarchive")
def test_deprecated_ocr_type(self):
def test_deprecated_ocr_type(self) -> None:
"""
GIVEN:
- Default settings
@@ -131,7 +131,7 @@ class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn("deprecated", msg.msg)
@override_settings(OCR_SKIP_ARCHIVE_FILE="invalid")
def test_invalid_ocr_skip_archive_file(self):
def test_invalid_ocr_skip_archive_file(self) -> None:
"""
GIVEN:
- Default settings
@@ -149,7 +149,7 @@ class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn('OCR_SKIP_ARCHIVE_FILE setting "invalid"', msg.msg)
@override_settings(OCR_CLEAN="cleanme")
def test_invalid_ocr_clean(self):
def test_invalid_ocr_clean(self) -> None:
"""
GIVEN:
- Default settings
@@ -169,7 +169,7 @@ class TestOcrSettingsChecks(DirectoriesMixin, TestCase):
class TestTimezoneSettingsChecks(DirectoriesMixin, TestCase):
@override_settings(TIME_ZONE="TheMoon\\MyCrater")
def test_invalid_timezone(self):
def test_invalid_timezone(self) -> None:
"""
GIVEN:
- Default settings
@@ -189,7 +189,7 @@ class TestTimezoneSettingsChecks(DirectoriesMixin, TestCase):
class TestBarcodeSettingsChecks(DirectoriesMixin, TestCase):
@override_settings(CONSUMER_BARCODE_SCANNER="Invalid")
def test_barcode_scanner_invalid(self):
def test_barcode_scanner_invalid(self) -> None:
msgs = settings_values_check(None)
self.assertEqual(len(msgs), 1)
@@ -198,7 +198,7 @@ class TestBarcodeSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn('Invalid Barcode Scanner "Invalid"', msg.msg)
@override_settings(CONSUMER_BARCODE_SCANNER="")
def test_barcode_scanner_empty(self):
def test_barcode_scanner_empty(self) -> None:
msgs = settings_values_check(None)
self.assertEqual(len(msgs), 1)
@@ -207,14 +207,14 @@ class TestBarcodeSettingsChecks(DirectoriesMixin, TestCase):
self.assertIn('Invalid Barcode Scanner ""', msg.msg)
@override_settings(CONSUMER_BARCODE_SCANNER="PYZBAR")
def test_barcode_scanner_valid(self):
def test_barcode_scanner_valid(self) -> None:
msgs = settings_values_check(None)
self.assertEqual(len(msgs), 0)
class TestEmailCertSettingsChecks(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
@override_settings(EMAIL_CERTIFICATE_FILE=Path("/tmp/not_actually_here.pem"))
def test_not_valid_file(self):
def test_not_valid_file(self) -> None:
"""
GIVEN:
- Default settings
@@ -236,7 +236,7 @@ class TestEmailCertSettingsChecks(DirectoriesMixin, FileSystemAssertsMixin, Test
class TestAuditLogChecks(TestCase):
def test_was_enabled_once(self):
def test_was_enabled_once(self) -> None:
"""
GIVEN:
- Audit log is not enabled

View File

@@ -15,7 +15,7 @@ from paperless.settings import _parse_cachalot_settings
from paperless.settings import _parse_caches
def test_all_redis_caches_have_same_custom_prefix(monkeypatch):
def test_all_redis_caches_have_same_custom_prefix(monkeypatch) -> None:
"""
Check that when setting a custom Redis prefix,
it is set for both the Django default cache and the read cache.
@@ -29,7 +29,7 @@ def test_all_redis_caches_have_same_custom_prefix(monkeypatch):
class TestDbCacheSettings:
def test_cachalot_default_settings(self):
def test_cachalot_default_settings(self) -> None:
# Cachalot must be installed even if disabled,
# so the cache can be invalidated anytime
assert "cachalot" not in settings.INSTALLED_APPS
@@ -62,7 +62,7 @@ class TestDbCacheSettings:
"PAPERLESS_READ_CACHE_TTL": "7200",
},
)
def test_cachalot_custom_settings(self):
def test_cachalot_custom_settings(self) -> None:
settings = _parse_cachalot_settings()
assert settings["CACHALOT_ENABLED"]
@@ -95,7 +95,7 @@ class TestDbCacheSettings:
self,
env_var_ttl: int,
expected_cachalot_timeout: int,
):
) -> None:
with patch.dict(os.environ, {"PAPERLESS_READ_CACHE_TTL": f"{env_var_ttl}"}):
cachalot_timeout = _parse_cachalot_settings()["CACHALOT_TIMEOUT"]
assert cachalot_timeout == expected_cachalot_timeout
@@ -106,7 +106,7 @@ class TestDbCacheSettings:
CACHALOT_TIMEOUT=1,
)
@pytest.mark.django_db(transaction=True)
def test_cache_hit_when_enabled():
def test_cache_hit_when_enabled() -> None:
cachalot_settings.reload()
assert cachalot_settings.CACHALOT_ENABLED
@@ -141,7 +141,7 @@ def test_cache_hit_when_enabled():
@pytest.mark.django_db(transaction=True)
def test_cache_is_disabled_by_default():
def test_cache_is_disabled_by_default() -> None:
cachalot_settings.reload()
# Invalidate the cache just in case
invalidate_db_cache()

View File

@@ -12,14 +12,14 @@ from paperless.settings import _parse_remote_user_settings
class TestRemoteUser(DirectoriesMixin, APITestCase):
def setUp(self):
def setUp(self) -> None:
super().setUp()
self.user = User.objects.create_superuser(
username="temp_admin",
)
def test_remote_user(self):
def test_remote_user(self) -> None:
"""
GIVEN:
- Configured user
@@ -54,7 +54,7 @@ class TestRemoteUser(DirectoriesMixin, APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_remote_user_api(self):
def test_remote_user_api(self) -> None:
"""
GIVEN:
- Configured user
@@ -100,7 +100,7 @@ class TestRemoteUser(DirectoriesMixin, APITestCase):
],
},
)
def test_remote_user_api_disabled(self):
def test_remote_user_api_disabled(self) -> None:
"""
GIVEN:
- Configured user
@@ -123,7 +123,7 @@ class TestRemoteUser(DirectoriesMixin, APITestCase):
[status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN],
)
def test_remote_user_header_setting(self):
def test_remote_user_header_setting(self) -> None:
"""
GIVEN:
- Remote user header name is set

View File

@@ -21,7 +21,7 @@ class TestIgnoreDateParsing(TestCase):
Tests the parsing of the PAPERLESS_IGNORE_DATES setting value
"""
def _parse_checker(self, test_cases):
def _parse_checker(self, test_cases) -> None:
"""
Helper function to check ignore date parsing
@@ -34,7 +34,7 @@ class TestIgnoreDateParsing(TestCase):
expected_date_set,
)
def test_no_ignore_dates_set(self):
def test_no_ignore_dates_set(self) -> None:
"""
GIVEN:
- No ignore dates are set
@@ -43,7 +43,7 @@ class TestIgnoreDateParsing(TestCase):
"""
self.assertSetEqual(_parse_ignore_dates(""), set())
def test_single_ignore_dates_set(self):
def test_single_ignore_dates_set(self) -> None:
"""
GIVEN:
- Ignore dates are set per certain inputs
@@ -70,7 +70,7 @@ class TestIgnoreDateParsing(TestCase):
class TestThreadCalculation(TestCase):
def test_workers_threads(self):
def test_workers_threads(self) -> None:
"""
GIVEN:
- Certain CPU counts
@@ -96,7 +96,7 @@ class TestThreadCalculation(TestCase):
class TestRedisSocketConversion(TestCase):
def test_redis_socket_parsing(self):
def test_redis_socket_parsing(self) -> None:
"""
GIVEN:
- Various Redis connection URI formats
@@ -163,7 +163,7 @@ class TestCeleryScheduleParsing(TestCase):
LLM_INDEX_EXPIRE_TIME = 23.0 * 60.0 * 60.0
CLEANUP_EXPIRED_SHARE_BUNDLES_EXPIRE_TIME = 23.0 * 60.0 * 60.0
def test_schedule_configuration_default(self):
def test_schedule_configuration_default(self) -> None:
"""
GIVEN:
- No configured task schedules
@@ -224,7 +224,7 @@ class TestCeleryScheduleParsing(TestCase):
schedule,
)
def test_schedule_configuration_changed(self):
def test_schedule_configuration_changed(self) -> None:
"""
GIVEN:
- Email task is configured non-default
@@ -290,7 +290,7 @@ class TestCeleryScheduleParsing(TestCase):
schedule,
)
def test_schedule_configuration_disabled(self):
def test_schedule_configuration_disabled(self) -> None:
"""
GIVEN:
- Search index task is disabled
@@ -348,7 +348,7 @@ class TestCeleryScheduleParsing(TestCase):
schedule,
)
def test_schedule_configuration_disabled_all(self):
def test_schedule_configuration_disabled_all(self) -> None:
"""
GIVEN:
- All tasks are disabled
@@ -379,7 +379,7 @@ class TestCeleryScheduleParsing(TestCase):
class TestDBSettings(TestCase):
def test_db_timeout_with_sqlite(self):
def test_db_timeout_with_sqlite(self) -> None:
"""
GIVEN:
- PAPERLESS_DB_TIMEOUT is set
@@ -403,7 +403,7 @@ class TestDBSettings(TestCase):
databases["default"]["OPTIONS"],
)
def test_db_timeout_with_not_sqlite(self):
def test_db_timeout_with_not_sqlite(self) -> None:
"""
GIVEN:
- PAPERLESS_DB_TIMEOUT is set but db is not sqlite
@@ -437,7 +437,7 @@ class TestDBSettings(TestCase):
class TestPaperlessURLSettings(TestCase):
def test_paperless_url(self):
def test_paperless_url(self) -> None:
"""
GIVEN:
- PAPERLESS_URL is set
@@ -461,7 +461,7 @@ class TestPaperlessURLSettings(TestCase):
class TestPathSettings(TestCase):
def test_default_paths(self):
def test_default_paths(self) -> None:
"""
GIVEN:
- PAPERLESS_FORCE_SCRIPT_NAME is not set
@@ -481,7 +481,7 @@ class TestPathSettings(TestCase):
) # LOGOUT_REDIRECT_URL
@mock.patch("os.environ", {"PAPERLESS_FORCE_SCRIPT_NAME": "/paperless"})
def test_subpath(self):
def test_subpath(self) -> None:
"""
GIVEN:
- PAPERLESS_FORCE_SCRIPT_NAME is set
@@ -507,7 +507,7 @@ class TestPathSettings(TestCase):
"PAPERLESS_LOGOUT_REDIRECT_URL": "/foobar/",
},
)
def test_subpath_with_explicit_logout_url(self):
def test_subpath_with_explicit_logout_url(self) -> None:
"""
GIVEN:
- PAPERLESS_FORCE_SCRIPT_NAME is set and so is PAPERLESS_LOGOUT_REDIRECT_URL
@@ -537,5 +537,5 @@ class TestPathSettings(TestCase):
("en+zh-Hans+zh-Hant", ["en", "zh-Hans", "zh-Hant", "zh"]),
],
)
def test_parser_date_parser_languages(languages, expected):
def test_parser_date_parser_languages(languages, expected) -> None:
assert sorted(_parse_dateparser_languages(languages)) == sorted(expected)

View File

@@ -12,14 +12,14 @@ from paperless.signals import handle_social_account_updated
class TestFailedLoginLogging(TestCase):
def setUp(self):
def setUp(self) -> None:
super().setUp()
self.creds = {
"username": "john lennon",
}
def test_unauthenticated(self):
def test_unauthenticated(self) -> None:
"""
GIVEN:
- Request with no authentication provided
@@ -39,7 +39,7 @@ class TestFailedLoginLogging(TestCase):
],
)
def test_none(self):
def test_none(self) -> None:
"""
GIVEN:
- Request with no IP possible
@@ -60,7 +60,7 @@ class TestFailedLoginLogging(TestCase):
],
)
def test_public(self):
def test_public(self) -> None:
"""
GIVEN:
- Request with publicly routeable IP
@@ -83,7 +83,7 @@ class TestFailedLoginLogging(TestCase):
],
)
def test_private(self):
def test_private(self) -> None:
"""
GIVEN:
- Request with private range IP
@@ -110,7 +110,7 @@ class TestFailedLoginLogging(TestCase):
class TestSyncSocialLoginGroups(TestCase):
@override_settings(SOCIAL_ACCOUNT_SYNC_GROUPS=True)
def test_sync_enabled(self):
def test_sync_enabled(self) -> None:
"""
GIVEN:
- Enabled group syncing, a user, and a social login
@@ -137,7 +137,7 @@ class TestSyncSocialLoginGroups(TestCase):
self.assertEqual(list(user.groups.all()), [group])
@override_settings(SOCIAL_ACCOUNT_SYNC_GROUPS=False)
def test_sync_disabled(self):
def test_sync_disabled(self) -> None:
"""
GIVEN:
- Disabled group syncing, a user, and a social login
@@ -164,7 +164,7 @@ class TestSyncSocialLoginGroups(TestCase):
self.assertEqual(list(user.groups.all()), [])
@override_settings(SOCIAL_ACCOUNT_SYNC_GROUPS=True)
def test_no_groups(self):
def test_no_groups(self) -> None:
"""
GIVEN:
- Enabled group syncing, a user, and a social login with no groups
@@ -193,7 +193,7 @@ class TestSyncSocialLoginGroups(TestCase):
self.assertEqual(list(user.groups.all()), [])
@override_settings(SOCIAL_ACCOUNT_SYNC_GROUPS=True)
def test_userinfo_groups(self):
def test_userinfo_groups(self) -> None:
"""
GIVEN:
- Enabled group syncing, and `groups` nested under `userinfo`
@@ -224,7 +224,7 @@ class TestSyncSocialLoginGroups(TestCase):
self.assertEqual(list(user.groups.all()), [group])
@override_settings(SOCIAL_ACCOUNT_SYNC_GROUPS=True)
def test_id_token_groups_fallback(self):
def test_id_token_groups_fallback(self) -> None:
"""
GIVEN:
- Enabled group syncing, and `groups` only under `id_token`
@@ -261,7 +261,7 @@ class TestUserGroupDeletionCleanup(TestCase):
from ui_settings
"""
def test_user_group_deletion_cleanup(self):
def test_user_group_deletion_cleanup(self) -> None:
"""
GIVEN:
- Existing user
@@ -302,7 +302,7 @@ class TestUserGroupDeletionCleanup(TestCase):
self.assertEqual(permissions.get("default_view_groups"), [])
self.assertEqual(permissions.get("default_change_groups"), [])
def test_user_group_deletion_error_handling(self):
def test_user_group_deletion_error_handling(self) -> None:
"""
GIVEN:
- Existing user and group

View File

@@ -19,7 +19,7 @@ TEST_CHANNEL_LAYERS = {
@override_settings(CHANNEL_LAYERS=TEST_CHANNEL_LAYERS)
class TestWebSockets(TestCase):
async def test_no_auth(self):
async def test_no_auth(self) -> None:
communicator = WebsocketCommunicator(application, "/ws/status/")
connected, _ = await communicator.connect()
self.assertFalse(connected)
@@ -27,7 +27,7 @@ class TestWebSockets(TestCase):
@mock.patch("paperless.consumers.StatusConsumer.close")
@mock.patch("paperless.consumers.StatusConsumer._authenticated")
async def test_close_on_no_auth(self, _authenticated, mock_close):
async def test_close_on_no_auth(self, _authenticated, mock_close) -> None:
_authenticated.return_value = True
communicator = WebsocketCommunicator(application, "/ws/status/")
@@ -59,7 +59,7 @@ class TestWebSockets(TestCase):
mock_close.assert_called_once()
@mock.patch("paperless.consumers.StatusConsumer._authenticated")
async def test_auth(self, _authenticated):
async def test_auth(self, _authenticated) -> None:
_authenticated.return_value = True
communicator = WebsocketCommunicator(application, "/ws/status/")
@@ -69,7 +69,7 @@ class TestWebSockets(TestCase):
await communicator.disconnect()
@mock.patch("paperless.consumers.StatusConsumer._authenticated")
async def test_receive_status_update(self, _authenticated):
async def test_receive_status_update(self, _authenticated) -> None:
_authenticated.return_value = True
communicator = WebsocketCommunicator(application, "/ws/status/")
@@ -90,7 +90,7 @@ class TestWebSockets(TestCase):
await communicator.disconnect()
async def test_status_update_check_perms(self):
async def test_status_update_check_perms(self) -> None:
communicator = WebsocketCommunicator(application, "/ws/status/")
communicator.scope["user"] = mock.Mock()
@@ -137,7 +137,7 @@ class TestWebSockets(TestCase):
await communicator.disconnect()
@mock.patch("paperless.consumers.StatusConsumer._authenticated")
async def test_receive_documents_deleted(self, _authenticated):
async def test_receive_documents_deleted(self, _authenticated) -> None:
_authenticated.return_value = True
communicator = WebsocketCommunicator(application, "/ws/status/")
@@ -159,7 +159,7 @@ class TestWebSockets(TestCase):
await communicator.disconnect()
@mock.patch("channels.layers.InMemoryChannelLayer.group_send")
def test_manager_send_progress(self, mock_group_send):
def test_manager_send_progress(self, mock_group_send) -> None:
with ProgressManager(task_id="test") as manager:
manager.send_progress(
ProgressStatusOptions.STARTED,
@@ -190,7 +190,7 @@ class TestWebSockets(TestCase):
)
@mock.patch("channels.layers.InMemoryChannelLayer.group_send")
def test_manager_send_documents_deleted(self, mock_group_send):
def test_manager_send_documents_deleted(self, mock_group_send) -> None:
with DocumentsStatusManager() as manager:
manager.send_documents_deleted([1, 2, 3])