mirror of
https://github.com/jazzband/dj-database-url.git
synced 2026-05-17 03:31:11 +00:00
Update tests
This commit is contained in:
parent
15ac40b0a7
commit
cdb5d645ec
1 changed files with 6 additions and 6 deletions
|
|
@ -218,14 +218,14 @@ class DatabaseTestSuite(unittest.TestCase):
|
||||||
assert url["ENGINE"] == "django.db.backends.sqlite3"
|
assert url["ENGINE"] == "django.db.backends.sqlite3"
|
||||||
assert url["NAME"] == ":memory:"
|
assert url["NAME"] == ":memory:"
|
||||||
|
|
||||||
def test_sqlite_relative_url(self):
|
def test_sqlite_relative_url(self) -> None:
|
||||||
url = "sqlite:///db.sqlite3"
|
url = "sqlite:///db.sqlite3"
|
||||||
config = dj_database_url.parse(url)
|
config = dj_database_url.parse(url)
|
||||||
|
|
||||||
assert config["ENGINE"] == "django.db.backends.sqlite3"
|
assert config["ENGINE"] == "django.db.backends.sqlite3"
|
||||||
assert config["NAME"] == "db.sqlite3"
|
assert config["NAME"] == "db.sqlite3"
|
||||||
|
|
||||||
def test_sqlite_absolute_url(self):
|
def test_sqlite_absolute_url(self) -> None:
|
||||||
# 4 slashes are needed:
|
# 4 slashes are needed:
|
||||||
# two are part of scheme
|
# two are part of scheme
|
||||||
# one separates host:port from path
|
# one separates host:port from path
|
||||||
|
|
@ -638,7 +638,7 @@ class DatabaseTestSuite(unittest.TestCase):
|
||||||
'WARNING:root:No DATABASE_URL environment variable set, and so no databases setup'
|
'WARNING:root:No DATABASE_URL environment variable set, and so no databases setup'
|
||||||
], cm.output
|
], cm.output
|
||||||
|
|
||||||
def test_credentials_unquoted__raise_value_error(self):
|
def test_credentials_unquoted__raise_value_error(self) -> None:
|
||||||
expected_message = (
|
expected_message = (
|
||||||
"This string is not a valid url, possibly because some of its parts "
|
"This string is not a valid url, possibly because some of its parts "
|
||||||
r"is not properly urllib.parse.quote()'ed."
|
r"is not properly urllib.parse.quote()'ed."
|
||||||
|
|
@ -646,13 +646,13 @@ class DatabaseTestSuite(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(ValueError, re.escape(expected_message)):
|
with self.assertRaisesRegex(ValueError, re.escape(expected_message)):
|
||||||
dj_database_url.parse("postgres://user:passw#ord!@localhost/foobar")
|
dj_database_url.parse("postgres://user:passw#ord!@localhost/foobar")
|
||||||
|
|
||||||
def test_credentials_quoted__ok(self):
|
def test_credentials_quoted__ok(self) -> None:
|
||||||
url = "postgres://user%40domain:p%23ssword!@localhost/foobar"
|
url = "postgres://user%40domain:p%23ssword!@localhost/foobar"
|
||||||
config = dj_database_url.parse(url)
|
config = dj_database_url.parse(url)
|
||||||
assert config["USER"] == "user@domain"
|
assert config["USER"] == "user@domain"
|
||||||
assert config["PASSWORD"] == "p#ssword!"
|
assert config["PASSWORD"] == "p#ssword!"
|
||||||
|
|
||||||
def test_unknown_scheme__raise_value_error(self):
|
def test_unknown_scheme__raise_value_error(self) -> None:
|
||||||
expected_message = (
|
expected_message = (
|
||||||
"Scheme 'unknown-scheme://' is unknown. "
|
"Scheme 'unknown-scheme://' is unknown. "
|
||||||
"Did you forget to register custom backend? Following schemes have registered backends:"
|
"Did you forget to register custom backend? Following schemes have registered backends:"
|
||||||
|
|
@ -660,7 +660,7 @@ class DatabaseTestSuite(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(ValueError, re.escape(expected_message)):
|
with self.assertRaisesRegex(ValueError, re.escape(expected_message)):
|
||||||
dj_database_url.parse("unknown-scheme://user:password@localhost/foobar")
|
dj_database_url.parse("unknown-scheme://user:password@localhost/foobar")
|
||||||
|
|
||||||
def test_register_multiple_times__no_duplicates_in_uses_netloc(self):
|
def test_register_multiple_times__no_duplicates_in_uses_netloc(self) -> None:
|
||||||
# make sure that when register() function is misused,
|
# make sure that when register() function is misused,
|
||||||
# it won't pollute urllib.parse.uses_netloc list with duplicates.
|
# it won't pollute urllib.parse.uses_netloc list with duplicates.
|
||||||
# Otherwise, it might cause performance issue if some code assumes that
|
# Otherwise, it might cause performance issue if some code assumes that
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue