diff --git a/tests/test_db.py b/tests/test_db.py index f155064..e26c535 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -197,6 +197,16 @@ def test_db_parsing(url, engine, name, host, user, passwd, port): assert config['OPTIONS'] == {'reconnect': 'true'} +def test_custom_db_engine(): + """Override ENGINE determined from schema.""" + env_url = 'postgres://enigma:secret@example.com:5431/dbname' + + engine = 'mypackage.backends.whatever' + url = Env.db_url_config(env_url, engine=engine) + + assert url['ENGINE'] == engine + + def test_postgres_complex_db_name_parsing(): """Make sure we can use complex postgres host.""" env_url = ( diff --git a/tests/test_email.py b/tests/test_email.py index c59ad83..1c9a875 100644 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -22,3 +22,13 @@ def test_smtp_parsing(): assert url['EMAIL_PORT'] == 587 assert url['EMAIL_USE_TLS'] is True assert url['EMAIL_FILE_PATH'] == '' + + +def test_custom_email_backend(): + """Override EMAIL_BACKEND determined from schema.""" + url = 'smtps://user@domain.com:password@smtp.example.com:587' + + backend = 'mypackage.backends.whatever' + url = Env.email_url_config(url, backend=backend) + + assert url['EMAIL_BACKEND'] == backend diff --git a/tests/test_search.py b/tests/test_search.py index 8130921..38f11f7 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -86,6 +86,16 @@ def test_elasticsearch_parsing(url, engine, scheme): assert url["URL"].startswith(scheme + ":") +def test_custom_search_engine(): + """Override ENGINE determined from schema.""" + env_url = 'elasticsearch://127.0.0.1:9200/index' + + engine = 'mypackage.backends.whatever' + url = Env.db_url_config(env_url, engine=engine) + + assert url['ENGINE'] == engine + + @pytest.mark.parametrize('storage', ['file', 'ram']) def test_whoosh_parsing(whoosh_url, storage): post_limit = 128 * 1024 * 1024