Open karambaq opened 1 year ago
I found the solution, but not sure that if this is the right one.
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': os.environ.get('DB_NAME'),
'USER': os.environ.get('DB_USERNAME'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOSTNAME'),
'PORT': os.environ.get('DB_PORT'),
},
LOG_DB: {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('LOG_DB_NAME'),
'USER': os.environ.get('LOG_DB_USERNAME'),
'PASSWORD': os.environ.get('LOG_DB_PASSWORD'),
'HOST': os.environ.get('LOG_DB_HOSTNAME'),
'PORT': os.environ.get('LOG_DB_PORT'),
}
}
In my settings I had two databases in DATABASES
dict, after I comment out the second one, all works as expected. But how can I specify to use only first database for pytest?
I've docker-compose configuration for django and postgres, it works fine. However, when I'm trying to run pytest inside a django container it fails with an error:
This is actually true, there is no such file in django container, it's inside the psql container, but I don't understand what to do with this error. I checked that test database created.
I can fix this error if add this fixture in
conftest.py
But using this approach it using my actual database, not the "test_*" one.
I don't think that this is docker-compose problem because other than tests it works fine.