简体   繁体   中英

Testing Django with MongoDB(Djongo)

I'm looking for a way to test my Django app that works with MongoDB using Djongo.

I found Django Test Addons library but as I understood, it only works with mongoengine. Is there any manner to make it work with Djongo or do you know another similar library that I can use?

I just run my django tests with own config:

manage.py test --settings=myproject.settings.unit_tests

In my unit test config, I just import my base settings, and then change database name. This seems to work fine.

from .base import *

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        'NAME': 'test_myproject',
        'CLIENT': {
            'host': 'myproject-mongodb',
            'username': 'supermongo',
            'password': 'supersecret',        
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM