A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
test cases
jonaswinkler2c3eaadbce9f
diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.pyindex 49dddee87..ba1ab45ca 100644--- a/src/documents/tests/test_api.py+++ b/src/documents/tests/test_api.py@@ -351,6 +351,25 @@ class TestDocumentApi(DirectoriesMixin, APITestCase):self.assertEqual(correction, None)+ def test_search_more_like(self):+ d1=Document.objects.create(title="invoice", content="the thing i bought at a shop and paid with bank account", checksum="A", pk=1)+ d2=Document.objects.create(title="bank statement 1", content="things i paid for in august", pk=2, checksum="B")+ d3=Document.objects.create(title="bank statement 3", content="things i paid for in september", pk=3, checksum="C")+ with AsyncWriter(index.open_index()) as writer:+ index.update_document(writer, d1)+ index.update_document(writer, d2)+ index.update_document(writer, d3)++ response = self.client.get(f"/api/search/?more_like={d2.id}")++ self.assertEqual(response.status_code, 200)++ results = response.data['results']++ self.assertEqual(len(results), 2)+ self.assertEqual(results[0]['id'], d3.id)+ self.assertEqual(results[1]['id'], d1.id)+def test_statistics(self):doc1 = Document.objects.create(title="none1", checksum="A")diff --git a/src/documents/views.py b/src/documents/views.pyindex bd9a748e8..59fbfb213 100755--- a/src/documents/views.py+++ b/src/documents/views.py@@ -348,6 +348,14 @@ class SearchView(APIView):more_like_id = Nonemore_like_content = None+ if not query and not more_like_id:+ return Response({+ 'count': 0,+ 'page': 0,+ 'page_count': 0,+ 'corrected_query': None,+ 'results': []})+try:page = int(request.query_params.get('page', 1))except (ValueError, TypeError):