Skip to content

Commit

Permalink
Update config test_options adding unitest
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseymour committed Dec 13, 2022
1 parent 3c1a39b commit 7aa7afd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def config(
conn_max_age=0,
conn_health_checks=False,
ssl_require=False,
test_options={},
test_options=None,
):
"""Returns configured DATABASE dictionary from DATABASE_URL."""
s = os.environ.get(env, default)
Expand Down
11 changes: 11 additions & 0 deletions test_dj_database_url.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import unittest
from unittest import mock

import dj_database_url

Expand Down Expand Up @@ -530,6 +531,16 @@ def test_sqlite_memory_persistent_connection_variables(self):
assert "CONN_MAX_AGE" not in url
assert "CONN_HEALTH_CHECKS" not in url

@mock.patch.dict(
os.environ,
{"DATABASE_URL": "postgres://user:password@instance.amazonaws.com:5431/d8r8?"},
)
def test_persistent_connection_variables_config(self):
url = dj_database_url.config(conn_max_age=600, conn_health_checks=True)

assert url["CONN_MAX_AGE"] == 600
assert url["CONN_HEALTH_CHECKS"] is True


if __name__ == "__main__":
unittest.main()

0 comments on commit 7aa7afd

Please sign in to comment.