mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-01 11:19:32 -05:00
Resolves test issues with Python 3.12 (#6902)
This commit is contained in:
parent
f9e2a66153
commit
2d73a46666
@ -485,6 +485,9 @@ class ConsumerPlugin(
|
|||||||
Return the document object if it was successfully created.
|
Return the document object if it was successfully created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
tempdir = None
|
||||||
|
|
||||||
|
try:
|
||||||
self._send_progress(
|
self._send_progress(
|
||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
@ -516,9 +519,11 @@ class ConsumerPlugin(
|
|||||||
self.log.debug(f"Detected mime type: {mime_type}")
|
self.log.debug(f"Detected mime type: {mime_type}")
|
||||||
|
|
||||||
# Based on the mime type, get the parser for that type
|
# Based on the mime type, get the parser for that type
|
||||||
parser_class: Optional[type[DocumentParser]] = get_parser_class_for_mime_type(
|
parser_class: Optional[type[DocumentParser]] = (
|
||||||
|
get_parser_class_for_mime_type(
|
||||||
mime_type,
|
mime_type,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
if not parser_class:
|
if not parser_class:
|
||||||
tempdir.cleanup()
|
tempdir.cleanup()
|
||||||
self._fail(
|
self._fail(
|
||||||
@ -535,6 +540,10 @@ class ConsumerPlugin(
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.run_pre_consume_script()
|
self.run_pre_consume_script()
|
||||||
|
except:
|
||||||
|
if tempdir:
|
||||||
|
tempdir.cleanup()
|
||||||
|
raise
|
||||||
|
|
||||||
def progress_callback(current_progress, max_progress): # pragma: no cover
|
def progress_callback(current_progress, max_progress): # pragma: no cover
|
||||||
# recalculate progress to be within 20 and 80
|
# recalculate progress to be within 20 and 80
|
||||||
@ -593,6 +602,9 @@ class ConsumerPlugin(
|
|||||||
archive_path = document_parser.get_archive_path()
|
archive_path = document_parser.get_archive_path()
|
||||||
|
|
||||||
except ParseError as e:
|
except ParseError as e:
|
||||||
|
document_parser.cleanup()
|
||||||
|
if tempdir:
|
||||||
|
tempdir.cleanup()
|
||||||
self._fail(
|
self._fail(
|
||||||
str(e),
|
str(e),
|
||||||
f"Error occurred while consuming document {self.filename}: {e}",
|
f"Error occurred while consuming document {self.filename}: {e}",
|
||||||
@ -601,6 +613,7 @@ class ConsumerPlugin(
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
document_parser.cleanup()
|
document_parser.cleanup()
|
||||||
|
if tempdir:
|
||||||
tempdir.cleanup()
|
tempdir.cleanup()
|
||||||
self._fail(
|
self._fail(
|
||||||
str(e),
|
str(e),
|
||||||
|
@ -70,12 +70,13 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
|||||||
config.app_logo = "/logo/example.jpg"
|
config.app_logo = "/logo/example.jpg"
|
||||||
config.save()
|
config.save()
|
||||||
response = self.client.get("/api/ui_settings/", format="json")
|
response = self.client.get("/api/ui_settings/", format="json")
|
||||||
self.assertDictContainsSubset(
|
self.assertDictEqual(
|
||||||
|
response.data["settings"],
|
||||||
{
|
{
|
||||||
"app_title": config.app_title,
|
"app_title": config.app_title,
|
||||||
"app_logo": config.app_logo,
|
"app_logo": config.app_logo,
|
||||||
},
|
}
|
||||||
response.data["settings"],
|
| response.data["settings"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_api_update_config(self):
|
def test_api_update_config(self):
|
||||||
|
@ -339,11 +339,12 @@ class TestDBSettings(TestCase):
|
|||||||
):
|
):
|
||||||
databases = _parse_db_settings()
|
databases = _parse_db_settings()
|
||||||
|
|
||||||
self.assertDictContainsSubset(
|
self.assertDictEqual(
|
||||||
{
|
databases["default"]["OPTIONS"],
|
||||||
|
databases["default"]["OPTIONS"]
|
||||||
|
| {
|
||||||
"connect_timeout": 10.0,
|
"connect_timeout": 10.0,
|
||||||
},
|
},
|
||||||
databases["default"]["OPTIONS"],
|
|
||||||
)
|
)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user