Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for kwarg overriding engine/backend from urls #518

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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
Loading