diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index ed9e8b0..4c1fd1f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -14,8 +14,8 @@ jobs:
strategy:
matrix:
- python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
- mongodb-version: ['4.2', '4.4', '5.0', '6.0']
+ python-version: ['3.10', '3.11', '3.12', '3.13']
+ mongodb-version: ['5.0', '6.0', '7.0', '8.0']
dservercore-version: [ main ]
dserver-search-plugin-mongo-version: [ main ]
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 8931b40..f5a0ee3 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,6 +4,23 @@ CHANGELOG
This project uses `semantic versioning `_.
This change log uses principles from `keep a changelog `_.
+[Unreleased]
+------------
+
+Changed
+^^^^^^^
+
+- Dropped support for Python 3.7–3.9; minimum is now Python 3.10
+- Updated CI Python matrix to 3.10–3.13; updated MongoDB matrix to 5.0–8.0
+
+Fixed
+^^^^^
+
+- Test fixtures: hardcoded MongoDB URI replaced by ``MONGO_URI`` environment variable (default: ``mongodb://localhost:27017/``)
+- Test fixtures: added ``client.close()`` after ``drop_database()`` in teardown to prevent connection pool exhaustion
+- Test fixtures: removed stale ``FLASK_ENV`` key from app config (removed in Flask 3.0)
+- Config route test: URI assertion now reads from ``MONGO_URI`` environment variable
+
[0.4.2]
-------
diff --git a/pyproject.toml b/pyproject.toml
index 5829c47..bfd480e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -12,6 +12,7 @@ authors = [
{name = "Johannes L. Hörmann", email = "johannes.laurin@gmail.com"},
]
dynamic = ["version"]
+requires-python = ">=3.10"
dependencies = [
"pymongo",
"dtoolcore>=3.18.0",
diff --git a/tests/conftest.py b/tests/conftest.py
index a436a43..3f8b24c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,6 @@
"""Reusable fixtures"""
+import os
import random
import string
@@ -7,6 +8,7 @@
JWT_PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8LrEp0Q6l1WPsY32uOPqEjaisQScnzO/XvlhQTzj5w+hFObjiNgIaHRceYh3hZZwsRsHIkCxOY0JgUPeFP9IVXso0VptIjCPRF5yrV/+dF1rtl4eyYj/XOBvSDzbQQwqdjhHffw0TXW0f/yjGGJCYM+tw/9dmj9VilAMNTx1H76uPKUo4M3vLBQLo2tj7z1jlh4Jlw5hKBRcWQWbpWP95p71Db6gSpqReDYbx57BW19APMVketUYsXfXTztM/HWz35J9HDya3ID0Dl+pE22Wo8SZo2+ULKu/4OYVcD8DjF15WwXrcuFDypX132j+LUWOVWxCs5hdMybSDwF3ZhVBH ec2-user@ip-172-31-41-191.eu-west-1.compute.internal" # NOQA
+MONGO_URI = os.environ.get("MONGO_URI", "mongodb://localhost:27017/")
def random_string(
@@ -41,12 +43,11 @@ def tmp_app_with_users(request):
"OPENAPI_VERSION": '3.0.2',
"CONFIG_SECRETS_TO_OBFUSCATE": [],
"SECRET_KEY": "secret",
- "FLASK_ENV": "development",
"SQLALCHEMY_DATABASE_URI": "sqlite:///:memory:",
- "RETRIEVE_MONGO_URI": "mongodb://localhost:27017/",
+ "RETRIEVE_MONGO_URI": MONGO_URI,
"RETRIEVE_MONGO_DB": tmp_mongo_db_name,
"RETRIEVE_MONGO_COLLECTION": "datasets",
- "SEARCH_MONGO_URI": "mongodb://localhost:27017/",
+ "SEARCH_MONGO_URI": MONGO_URI,
"SEARCH_MONGO_DB": tmp_mongo_db_name,
"SEARCH_MONGO_COLLECTION": "datasets",
"SQLALCHEMY_TRACK_MODIFICATIONS": False,
@@ -84,7 +85,9 @@ def tmp_app_with_users(request):
@request.addfinalizer
def teardown():
current_app.retrieve.client.drop_database(tmp_mongo_db_name)
+ current_app.retrieve.client.close()
current_app.search.client.drop_database(tmp_mongo_db_name)
+ current_app.search.client.close()
sql_db.session.remove()
- return app.test_client()
\ No newline at end of file
+ return app.test_client()
diff --git a/tests/test_config_route.py b/tests/test_config_route.py
index e81125a..7db0ec8 100644
--- a/tests/test_config_route.py
+++ b/tests/test_config_route.py
@@ -1,6 +1,7 @@
"""Test the /config blueprint route."""
import json
+import os
import dserver_retrieve_plugin_mongo
from .utils import compare_nested
@@ -17,7 +18,7 @@ def test_config_info_route(tmp_app_with_users, snowwhite_token): # NOQA
expected_content = {
'retrieve_mongo_collection': 'datasets',
- 'retrieve_mongo_uri': 'mongodb://localhost:27017/',
+ 'retrieve_mongo_uri': os.environ.get("MONGO_URI", "mongodb://localhost:27017/"),
}
response = json.loads(r.data.decode("utf-8"))
diff --git a/tests/test_utils_retrieve_standalone.py b/tests/test_utils_retrieve_standalone.py
index 410fa34..d96d2b7 100644
--- a/tests/test_utils_retrieve_standalone.py
+++ b/tests/test_utils_retrieve_standalone.py
@@ -20,8 +20,8 @@
# This tested in this module.
from dserver_retrieve_plugin_mongo.utils_retrieve import MongoRetrieve
-
-MONGO_URI = "mongodb://localhost:27017"
+import os
+MONGO_URI = os.environ.get("MONGO_URI", "mongodb://localhost:27017/")
def random_string(
@@ -40,6 +40,7 @@ def tmp_mongo_db(request):
@request.addfinalizer
def teardown():
client.drop_database(tmp_mongo_db_name)
+ client.close()
return tmp_mongo_db_name