Skip to content

Commit

Permalink
Add tests for kwarg overriding engine/backend from urls
Browse files Browse the repository at this point in the history
  • Loading branch information
fdemmer authored and sergeyklay committed Nov 4, 2024
1 parent d92e11b commit 6abdb86
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]: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 = (
Expand Down
10 changes: 10 additions & 0 deletions tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]:[email protected]:587'

backend = 'mypackage.backends.whatever'
url = Env.email_url_config(url, backend=backend)

assert url['EMAIL_BACKEND'] == backend
10 changes: 10 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6abdb86

Please sign in to comment.