Created
October 31, 2011 08:54
-
-
Save gipi/1327143 to your computer and use it in GitHub Desktop.
Configure a Django project to use a specific database to use when run tests if we can't create databases with the user credential defined in the 'default' one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Since we need a syncdb on all the databases, before the tests can be | |
# runned successfully we need to execute | |
# | |
# $ python manage.py syncdb | |
# $ python manage.py syncdb --database=test | |
# | |
# otherwise will be errors like | |
# | |
# 'django.db.utils.DatabaseError: no such table: django_site' | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
'NAME': 'bla', | |
'USER': 'foo' | |
'PASSWORD': 'bar' | |
}, | |
'test': { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': 'only4test.sqlite' | |
}, | |
} | |
# http://stackoverflow.com/questions/4650509/different-db-for-testing-in-django | |
import sys | |
if 'test' in sys.argv: | |
DATABASES['default'] = DATABASES['test']; |
i think in last line this should be the code DATABASES['test'] = DATABASES['default']
I am actually trying to give a replica of my db as testing db so i can test my api and database without configuring multiple foriegn keys and appending data accordingly just for test of a put api
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, all this time I was ignoring the last line of code, very sad to have wasted time on such small things...