python - Django: How to access test database? -


i working in django 1.8. have django management command create materialized views on database, follows:

python manage.py create_db_matviews $db_name $db_user $db_pass 

now want run management command inside tests, can test command. (my actual database extremely large, , management command extremely slow, test on test data, rather real data.)

however calling management command inside test file not work - unsurprisingly since have no idea credentials use:

def setupmodule():     management.call_command('loaddata', 'frontend/fixtures/mydata.json',                         verbosity=0)     # load fixtures, then...      management.call_command('create_db_matviews',                             'default', 'default', 'randomguess',                              verbosity=0) 

it fails follows:

creating test database alias 'default' ('test_prescribing')... ... running migrations...   ====================================================================== error: setupmodule (frontend.tests.test_api_views) ---------------------------------------------------------------------- traceback (most recent call last):   file "/users/.../tests/test_api_views.py", line 23, in setupmodule     verbosity=0)   file "/users/.../.virtualenvs/openprescribing/lib/python2.7/site-packages/django/core/management/__init__.py", line 115, in call_command     return klass.execute(*args, **defaults)   file "/users/.../.virtualenvs/openprescribing/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute     output = self.handle(*args, **options)   file "/users/.../frontend/management/commands/create_indexes_and_matviews.py", line 19, in handle     password=db_pass)   file "/users/.../.virtualenvs/openprescribing/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect     conn = _connect(dsn, connection_factory=connection_factory, async=async) operationalerror: fatal:  role "default" not exist 

what credentials should use access test database?

this section of django docs has details.

basically name of test database per settings file test_ prefixed, , user , password settings file.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -