Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev' into feature-bulk-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaswinkler committed Dec 22, 2020
2 parents 1c3b852 + 6968e22 commit cd8f99d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/documents/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def parser_check(app_configs, **kwargs):

if len(parsers) == 0:
return [Error("No parsers found. This is a bug. The consumer won't be "
"able to onsume any documents without parsers.")]
"able to consume any documents without parsers.")]
else:
return []
11 changes: 6 additions & 5 deletions src/documents/management/commands/document_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.management import BaseCommand
from django.db import transaction

from documents.mixins import Renderable
from documents.tasks import index_reindex, index_optimize
Expand All @@ -18,8 +19,8 @@ def add_arguments(self, parser):
def handle(self, *args, **options):

self.verbosity = options["verbosity"]

if options['command'] == 'reindex':
index_reindex()
elif options['command'] == 'optimize':
index_optimize()
with transaction.atomic():
if options['command'] == 'reindex':
index_reindex()
elif options['command'] == 'optimize':
index_optimize()
15 changes: 14 additions & 1 deletion src/documents/tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import unittest
from unittest import mock

from django.core.checks import Error
from django.test import TestCase

from .factories import DocumentFactory
from ..checks import changed_password_check
from .. import document_consumer_declaration
from ..checks import changed_password_check, parser_check
from ..models import Document


Expand All @@ -15,3 +18,13 @@ def test_changed_password_check_empty_db(self):
def test_changed_password_check_no_encryption(self):
DocumentFactory.create(storage_type=Document.STORAGE_TYPE_UNENCRYPTED)
self.assertEqual(changed_password_check(None), [])

def test_parser_check(self):

self.assertEqual(parser_check(None), [])

with mock.patch('documents.checks.document_consumer_declaration.send') as m:
m.return_value = []

self.assertEqual(parser_check(None), [Error("No parsers found. This is a bug. The consumer won't be "
"able to consume any documents without parsers.")])

0 comments on commit cd8f99d

Please sign in to comment.