aboutsummaryrefslogtreecommitdiff
path: root/tests/test_optional_dependencies.py
diff options
context:
space:
mode:
authorDennis Fink2026-10-31 08:43:03 +0100
committerDennis Fink2026-10-31 08:46:58 +0100
commit40ae4a862e00475a5b1c205045986475a790f39c (patch)
treee044f9ae0019ebe2860dbc9c2258aa7dfb492955 /tests/test_optional_dependencies.py
parent53370723df05193938ce3c2d55a8e12f2a87b17b (diff)
downloadwebmentions-ssg-40ae4a862e00475a5b1c205045986475a790f39c.tar.gz
webmentions-ssg-40ae4a862e00475a5b1c205045986475a790f39c.zip
build: add storage backend dependency groups
Provide matching published extras and uv groups for Redis, Valkey, Memcached, MongoDB, and PostgreSQL so deployments can install the clients required by their selected rate-limit or Huey backend. Keep shared backend groups aligned where Redis dependencies are used by both Flask-Limiter and Huey.
Diffstat (limited to '')
-rw-r--r--tests/test_optional_dependencies.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_optional_dependencies.py b/tests/test_optional_dependencies.py
new file mode 100644
index 0000000..40c53c5
--- /dev/null
+++ b/tests/test_optional_dependencies.py
@@ -0,0 +1,38 @@
+# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""Check optional client dependencies for supported storage backends."""
+
+import tomllib
+from pathlib import Path
+
+import pytest
+
+
+BACKENDS = {
+ "redis": ["flask-limiter[redis]>=4.1.1", "huey[redis]>=3.3.0"],
+ "valkey": ["flask-limiter[valkey]>=4.1.1", "huey[redis]>=3.3.0"],
+ "memcached": ["flask-limiter[memcached]>=4.1.1"],
+ "mongodb": ["flask-limiter[mongodb]>=4.1.1"],
+ "postgres": ["huey[postgres]>=3.1.0"],
+}
+
+
+@pytest.mark.parametrize("backend", BACKENDS)
+def test_storage_backend_has_matching_extra_and_uv_group(backend: str) -> None:
+ project_root = Path(__file__).resolve().parents[1]
+ metadata = tomllib.loads((project_root / "pyproject.toml").read_text())
+
+ expected = BACKENDS[backend]
+ assert metadata["project"]["optional-dependencies"][backend] == expected
+ assert metadata["dependency-groups"][backend] == expected
+ assert metadata["tool"]["uv"]["default-groups"] == ["dev", "test"]
+
+
+def test_no_legacy_ratelimit_only_groups() -> None:
+ project_root = Path(__file__).resolve().parents[1]
+ metadata = tomllib.loads((project_root / "pyproject.toml").read_text())
+ assert not any(
+ group.startswith("ratelimit-") for group in metadata["dependency-groups"]
+ )