Testing¶
python manage.py test <app_name> –keepdb –nomigrations python manage.py test auto_import/tests/ –keepdb -n
In settings_local.py under DATABASE option
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'agregg',
'USER': 'root',
'PASSWORD': 'root',
'HOST': 'localhost',
'PORT': '5432',
'CONN_MAX_AGE': 600,
'TEST': {
'NAME': 'agregg',
},
}
}
To force the Login, in test setUp method use
def setUp(self):
self.client = Client()
self.client.post('/accounts/login/', {'username': 'admin', 'password': 'password', 'random_guid': '1234'})