-
Notifications
You must be signed in to change notification settings - Fork 2
/
testing.py
48 lines (38 loc) · 1.23 KB
/
testing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Django configuration for testing and CI environments."""
from .common import *
# Use in-memory file storage
DEFAULT_FILE_STORAGE = 'inmemorystorage.InMemoryStorage'
# Speed!
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',
)
# Fake out migrations to speed up tests
# cf. https://mastodon.social/@webology/99162173318389992
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return None
MIGRATION_MODULES = DisableMigrations()
# Database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
'TEST': {}
}
}
# Disable logging
import logging
logging.disable(logging.CRITICAL)
env = get_secret("ENVIRONMENT")
import sys
if os.path.isdir('/Volumes/RAMDisk') and not env == 'ci' and not 'create-db' in sys.argv:
# and this allows you to use --reuse-db to skip re-creating the db,
# even faster!
#
# To create the RAMDisk, use bash:
# $ hdiutil attach -nomount ram://$((2 * 1024 * SIZE_IN_MB))
# /dev/disk2
# $ diskutil eraseVolume HFS+ RAMDisk /dev/disk2
DATABASES['default']['TEST']['NAME'] = '/Volumes/RAMDisk/unkenmathe.test.db.sqlite3'