mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-10 10:07:15 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
197e62f2ee | ||
|
|
e9835a93ac |
No files matched your search
+10
-11
@@ -272,27 +272,26 @@ def check_deprecated_db_settings(
|
|||||||
Detects legacy advanced options that should be migrated to
|
Detects legacy advanced options that should be migrated to
|
||||||
PAPERLESS_DB_OPTIONS. Returns one Warning per deprecated variable found.
|
PAPERLESS_DB_OPTIONS. Returns one Warning per deprecated variable found.
|
||||||
"""
|
"""
|
||||||
deprecated_vars: dict[str, str] = {
|
deprecated_vars = (
|
||||||
"PAPERLESS_DB_TIMEOUT": "timeout",
|
"PAPERLESS_DB_TIMEOUT",
|
||||||
"PAPERLESS_DB_POOLSIZE": "pool.min_size / pool.max_size",
|
"PAPERLESS_DB_POOLSIZE",
|
||||||
"PAPERLESS_DBSSLMODE": "sslmode",
|
"PAPERLESS_DBSSLMODE",
|
||||||
"PAPERLESS_DBSSLROOTCERT": "sslrootcert",
|
"PAPERLESS_DBSSLROOTCERT",
|
||||||
"PAPERLESS_DBSSLCERT": "sslcert",
|
"PAPERLESS_DBSSLCERT",
|
||||||
"PAPERLESS_DBSSLKEY": "sslkey",
|
"PAPERLESS_DBSSLKEY",
|
||||||
}
|
)
|
||||||
|
|
||||||
warnings: list[Warning] = []
|
warnings: list[Warning] = []
|
||||||
|
|
||||||
for var_name, db_option_key in deprecated_vars.items():
|
for var_name in deprecated_vars:
|
||||||
if not os.getenv(var_name):
|
if not os.getenv(var_name):
|
||||||
continue
|
continue
|
||||||
warnings.append(
|
warnings.append(
|
||||||
Warning(
|
Warning(
|
||||||
f"Deprecated environment variable: {var_name}",
|
f"Deprecated environment variable: {var_name}",
|
||||||
hint=(
|
hint=(
|
||||||
f"{var_name} is no longer supported and will be removed in v3.2. "
|
f"{var_name} is deprecated. "
|
||||||
f"Set the equivalent option via PAPERLESS_DB_OPTIONS instead. "
|
f"Set the equivalent option via PAPERLESS_DB_OPTIONS instead. "
|
||||||
f'Example: PAPERLESS_DB_OPTIONS=\'{{"{db_option_key}": "<value>"}}\'. '
|
|
||||||
"See https://docs.paperless-ngx.com/migration-v3/ for the full reference."
|
"See https://docs.paperless-ngx.com/migration-v3/ for the full reference."
|
||||||
),
|
),
|
||||||
id="paperless.W001",
|
id="paperless.W001",
|
||||||
|
|||||||
@@ -211,14 +211,14 @@ class TestAuditLogChecks:
|
|||||||
assert "auditlog table was found but audit log is disabled." in msgs[0].msg
|
assert "auditlog table was found but audit log is disabled." in msgs[0].msg
|
||||||
|
|
||||||
|
|
||||||
DEPRECATED_VARS: dict[str, str] = {
|
DEPRECATED_VARS = (
|
||||||
"PAPERLESS_DB_TIMEOUT": "timeout",
|
"PAPERLESS_DB_TIMEOUT",
|
||||||
"PAPERLESS_DB_POOLSIZE": "pool.min_size / pool.max_size",
|
"PAPERLESS_DB_POOLSIZE",
|
||||||
"PAPERLESS_DBSSLMODE": "sslmode",
|
"PAPERLESS_DBSSLMODE",
|
||||||
"PAPERLESS_DBSSLROOTCERT": "sslrootcert",
|
"PAPERLESS_DBSSLROOTCERT",
|
||||||
"PAPERLESS_DBSSLCERT": "sslcert",
|
"PAPERLESS_DBSSLCERT",
|
||||||
"PAPERLESS_DBSSLKEY": "sslkey",
|
"PAPERLESS_DBSSLKEY",
|
||||||
}
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestDeprecatedDbSettings:
|
class TestDeprecatedDbSettings:
|
||||||
@@ -234,26 +234,11 @@ class TestDeprecatedDbSettings:
|
|||||||
result = check_deprecated_db_settings(None)
|
result = check_deprecated_db_settings(None)
|
||||||
assert result == []
|
assert result == []
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("env_var", DEPRECATED_VARS)
|
||||||
("env_var", "db_option_key"),
|
|
||||||
[
|
|
||||||
pytest.param("PAPERLESS_DB_TIMEOUT", "timeout", id="db-timeout"),
|
|
||||||
pytest.param(
|
|
||||||
"PAPERLESS_DB_POOLSIZE",
|
|
||||||
"pool.min_size / pool.max_size",
|
|
||||||
id="db-poolsize",
|
|
||||||
),
|
|
||||||
pytest.param("PAPERLESS_DBSSLMODE", "sslmode", id="ssl-mode"),
|
|
||||||
pytest.param("PAPERLESS_DBSSLROOTCERT", "sslrootcert", id="ssl-rootcert"),
|
|
||||||
pytest.param("PAPERLESS_DBSSLCERT", "sslcert", id="ssl-cert"),
|
|
||||||
pytest.param("PAPERLESS_DBSSLKEY", "sslkey", id="ssl-key"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
def test_single_deprecated_var_produces_one_warning(
|
def test_single_deprecated_var_produces_one_warning(
|
||||||
self,
|
self,
|
||||||
mocker: MockerFixture,
|
mocker: MockerFixture,
|
||||||
env_var: str,
|
env_var: str,
|
||||||
db_option_key: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Each deprecated var in isolation produces exactly one warning."""
|
"""Each deprecated var in isolation produces exactly one warning."""
|
||||||
mocker.patch.dict(os.environ, {env_var: "some_value"}, clear=True)
|
mocker.patch.dict(os.environ, {env_var: "some_value"}, clear=True)
|
||||||
@@ -264,7 +249,8 @@ class TestDeprecatedDbSettings:
|
|||||||
assert isinstance(warning, Warning)
|
assert isinstance(warning, Warning)
|
||||||
assert warning.id == "paperless.W001"
|
assert warning.id == "paperless.W001"
|
||||||
assert env_var in warning.hint
|
assert env_var in warning.hint
|
||||||
assert db_option_key in warning.hint
|
assert "PAPERLESS_DB_OPTIONS" in warning.hint
|
||||||
|
assert "https://docs.paperless-ngx.com/migration-v3/" in warning.hint
|
||||||
|
|
||||||
def test_multiple_deprecated_vars_produce_one_warning_each(
|
def test_multiple_deprecated_vars_produce_one_warning_each(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in new issue
Block a user