[Answered ]-Django project wait for database ready tests

1👍

Background for test utils

So you are creating a custom Command that you want to execute. Inside your command, you call the function check (see docs).

Regarding your test case. You are performing 2 test scenarios.
But before you run your tests you provide a patch. (See docs)

The patch will – if used as decorator – be injected either at constructor or function parameter. For your case patched_check. Your patched_check now acts as a mock of your check function.

What are the test cases doing?

test_wait_for_db_ready(self, patched_check) validates that self.check is called with the param databases=['default'] exactly once.

test_wait_for_db_delay validates that if the self.check throws an exception then time.sleep(1) is called 6 times.

0👍

I was facing the same issue, please checkout your database environment variables in docker-compose.yml file. You have misconfigured any of database environment variable.

Leave a comment