Django settings tips

Tips1

 1 from django.conf import settings
 2
 3 if settings.DEBUG:
 4     # pour les tests, à placer après le 2e ADRESSES_COURIEL
 5     ADRESSES_COURIEL = {
 6         "achat": ["patrick.vergain@xxx.yy"],
 7         "nomenclature": ["patrick.vergain@xxx.yy"],
 8         "service": ["patrick.vergain@xxx.yy"],
 9         "sortie": ["patrick.vergain@xxx.yy"],
10     }

Tips2

 1 """conftest.py
 2
 3
 4 For information, we could also use this code::
 5
 6     os.environ[
 7         "DATABASE_URL"
 8     ] = "postgresql://<username>:<password>@X.Y.Z.T:5432/db_xxxxxx"
 9     DATABASES = {"default": env.db("DATABASE_URL")}
10
11
12     # on corrige par anticipation car django-environ fait pointer sur
13     # 'django.db.backends.postgresql_psycopg2' au lieu de 'django.db.backends.postgresql'
14     # A ce jour (2017-12-01 les 2 modules existent.
15     # https://docs.docker.com/compose/django/#connect-the-database
16
17     DATABASES["default"]["ENGINE"] = "django.db.backends.postgresql"
18
19
20 Calling pytest::
21
22     pytest --cov='.'
23
24 """
25
26 import pytest
27 from django.conf import settings
28
29 # http://github.com/joke2k/django-environ
30 # import environ
31
32 @pytest.fixture(scope="session")
33 def django_db_setup():
34
35     settings.DATABASES["default"] = {
36         "ENGINE": "django.db.backends.postgresql",
37         # Test database
38         "HOST": "X.Y.Z.T",
39         "NAME": "db_xxx",
40     }