Coverage for documents/checks.py: 67%

18 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 09:07 +0000

1from django.conf import settings 

2from django.core.checks import Error 

3from django.core.checks import Warning 

4from django.core.checks import register 

5 

6from documents.templating.utils import convert_format_str_to_template_format 

7from paperless.parsers.registry import get_parser_registry 

8 

9 

10@register() 

11def parser_check(app_configs, **kwargs): 

12 if not get_parser_registry().all_parsers(): 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true

13 return [ 

14 Error( 

15 "No parsers found. This is a bug. The consumer won't be " 

16 "able to consume any documents without parsers.", 

17 ), 

18 ] 

19 return [] 

20 

21 

22@register() 

23def filename_format_check(app_configs, **kwargs): 

24 if settings.FILENAME_FORMAT: 24 ↛ 25line 24 didn't jump to line 25 because the condition on line 24 was never true

25 converted_format = convert_format_str_to_template_format( 

26 settings.FILENAME_FORMAT, 

27 ) 

28 if converted_format != settings.FILENAME_FORMAT: 

29 return [ 

30 Warning( 

31 f"Filename format {settings.FILENAME_FORMAT} is using the old style, please update to use double curly brackets", 

32 hint=converted_format, 

33 ), 

34 ] 

35 return []