mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 07:05:41 +00:00 
			
		
		
		
	Enforce usage of sqlite3 for running tests
- Simplifies tests by creating a database in memory - Does not affect the user setup at all
This commit is contained in:
		@@ -159,16 +159,28 @@ WSGI_APPLICATION = 'InvenTree.wsgi.application'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
DATABASES = {}
 | 
					DATABASES = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Database backend selection
 | 
					"""
 | 
				
			||||||
if 'database' in CONFIG:
 | 
					When running unit tests, enforce usage of sqlite3 database,
 | 
				
			||||||
    DATABASES['default'] = CONFIG['database']
 | 
					so that the tests can be run in RAM without any setup requirements
 | 
				
			||||||
else:
 | 
					"""
 | 
				
			||||||
    eprint("Warning: Database backend not specified - using default (sqlite)")
 | 
					if 'test' in sys.argv:
 | 
				
			||||||
 | 
					    eprint('Running tests - Using sqlite3 memory database')
 | 
				
			||||||
    DATABASES['default'] = {
 | 
					    DATABASES['default'] = {
 | 
				
			||||||
        'ENGINE': 'django.db.backends.sqlite3',
 | 
					        'ENGINE': 'django.db.backends.sqlite3',
 | 
				
			||||||
        'NAME': os.path.join(BASE_DIR, 'inventree_db.sqlite3'),
 | 
					        'NAME': 'test_db.sqlite3'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Database backend selection
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    if 'database' in CONFIG:
 | 
				
			||||||
 | 
					        DATABASES['default'] = CONFIG['database']
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        eprint("Warning: Database backend not specified - using default (sqlite)")
 | 
				
			||||||
 | 
					        DATABASES['default'] = {
 | 
				
			||||||
 | 
					            'ENGINE': 'django.db.backends.sqlite3',
 | 
				
			||||||
 | 
					            'NAME': os.path.join(BASE_DIR, 'inventree_db.sqlite3'),
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CACHES = {
 | 
					CACHES = {
 | 
				
			||||||
    'default': {
 | 
					    'default': {
 | 
				
			||||||
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
 | 
					        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user