mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Do some trickery to support Python 3.11 and mocking invalid module names
This commit is contained in:
		 Trenton Holmes
					Trenton Holmes
				
			
				
					committed by
					
						 Trenton H
						Trenton H
					
				
			
			
				
	
			
			
			 Trenton H
						Trenton H
					
				
			
						parent
						
							6c19a0f8c7
						
					
				
				
					commit
					fe7fb488c0
				
			| @@ -1,3 +1,4 @@ | ||||
| import importlib | ||||
| import shutil | ||||
| import tempfile | ||||
| from pathlib import Path | ||||
| @@ -10,12 +11,17 @@ from django.test import override_settings | ||||
|  | ||||
| from documents.tests.utils import TestMigrations | ||||
|  | ||||
| # https://github.com/python/cpython/issues/100950 | ||||
| migration_1037_obj = importlib.import_module( | ||||
|     "documents.migrations.1037_webp_encrypted_thumbnail_conversion", | ||||
| ) | ||||
|  | ||||
|  | ||||
| @override_settings(PASSPHRASE="test") | ||||
| @mock.patch( | ||||
|     "documents.migrations.1037_webp_encrypted_thumbnail_conversion.multiprocessing.pool.Pool.map", | ||||
|     f"{__name__}.migration_1037_obj.multiprocessing.pool.Pool.map", | ||||
| ) | ||||
| @mock.patch("documents.migrations.1037_webp_encrypted_thumbnail_conversion.run_convert") | ||||
| @mock.patch(f"{__name__}.migration_1037_obj.run_convert") | ||||
| class TestMigrateToEncrytpedWebPThumbnails(TestMigrations): | ||||
|     migrate_from = "1036_alter_savedviewfilterrule_rule_type" | ||||
|     migrate_to = "1037_webp_encrypted_thumbnail_conversion" | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| import importlib | ||||
| import shutil | ||||
| import tempfile | ||||
| from pathlib import Path | ||||
| @@ -10,11 +11,16 @@ from django.test import override_settings | ||||
|  | ||||
| from documents.tests.utils import TestMigrations | ||||
|  | ||||
| # https://github.com/python/cpython/issues/100950 | ||||
| migration_1021_obj = importlib.import_module( | ||||
|     "documents.migrations.1021_webp_thumbnail_conversion", | ||||
| ) | ||||
|  | ||||
|  | ||||
| @mock.patch( | ||||
|     "documents.migrations.1021_webp_thumbnail_conversion.multiprocessing.pool.Pool.map", | ||||
|     f"{__name__}.migration_1021_obj.multiprocessing.pool.Pool.map", | ||||
| ) | ||||
| @mock.patch("documents.migrations.1021_webp_thumbnail_conversion.run_convert") | ||||
| @mock.patch(f"{__name__}.migration_1021_obj.run_convert") | ||||
| class TestMigrateWebPThumbnails(TestMigrations): | ||||
|     migrate_from = "1020_merge_20220518_1839" | ||||
|     migrate_to = "1021_webp_thumbnail_conversion" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user