K
K
KIN19912019-01-05 15:05:33
Django
KIN1991, 2019-01-05 15:05:33

How to properly test Django channels?

Good day to all!
Actually a question on a subject.
I read the docks, it’s not clear such a moment where the tests should be stored and how to run them? Now I have them in the standard Django test file, but when the tests are run, the tests for channels do not run ...
What is the best way to organize tests of channels along with a Django application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Ryabykin, 2019-01-06
@geesoff

Hello.
That's what it says in the doc - put it in the tests.py file.
If you have other tests there besides those for channels and they work, then check that you have added the TEST argument to the DATABASES dictionary of the settings.py file.
"We need to tell our project that the sqlite3 database needs not to be in memory for run the tests."

# mysite/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'TEST': {
            'NAME': os.path.join(BASE_DIR, 'db_test.sqlite3')
        }
    }
}

If that doesn't help, try starting testing with the initial tests - _open_new_window(), _enter_chat_room('room_name'); if they don't work, it means that something was configured incorrectly for testing channels

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question