From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Tue, 12 Sep 2023 15:59:09 +0000 (-0700) Subject: Uses regex matching against the messages, as ordering and exact matched value don... X-Git-Tag: v2.0.0-beta.1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aa72f768faa3a8695c5cc28106f17de9265fded;p=thirdparty%2Fpaperless-ngx.git Uses regex matching against the messages, as ordering and exact matched value don't matter, just the count of matches --- diff --git a/src/documents/tests/test_management_fuzzy.py b/src/documents/tests/test_management_fuzzy.py index 4a3d96c461..abbf3c921e 100644 --- a/src/documents/tests/test_management_fuzzy.py +++ b/src/documents/tests/test_management_fuzzy.py @@ -8,6 +8,8 @@ from documents.models import Document class TestFuzzyMatchCommand(TestCase): + MSG_REGEX = r"Document \d fuzzy match to \d \(confidence \d\d\.\d\d\d\)" + def call_command(self, *args, **kwargs): stdout = StringIO() stderr = StringIO() @@ -114,7 +116,7 @@ class TestFuzzyMatchCommand(TestCase): filename="other_test.pdf", ) stdout, _ = self.call_command("--processes", "1") - self.assertEqual(stdout, "Document 1 fuzzy match to 2 (confidence 86.667)\n") + self.assertRegex(stdout, self.MSG_REGEX + "\n") def test_with_3_matches(self): """ @@ -152,6 +154,6 @@ class TestFuzzyMatchCommand(TestCase): stdout, _ = self.call_command() lines = [x.strip() for x in stdout.split("\n") if len(x.strip())] self.assertEqual(len(lines), 3) - self.assertEqual(lines[0], "Document 1 fuzzy match to 2 (confidence 86.667)") - self.assertEqual(lines[1], "Document 1 fuzzy match to 3 (confidence 88.136)") - self.assertEqual(lines[2], "Document 2 fuzzy match to 3 (confidence 88.525)") + self.assertRegex(lines[0], self.MSG_REGEX) + self.assertRegex(lines[1], self.MSG_REGEX) + self.assertRegex(lines[2], self.MSG_REGEX)