From 4d155ac084f13246374142b70c8d429230471173 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Thu, 5 Dec 2024 15:48:26 -0500 Subject: [PATCH] pymongo driver does not support conn_* --- README.md | 4 +--- django_mongodb/utils.py | 4 +--- tests/utils_/test_parse_uri.py | 8 -------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index df944672..5e6b7bac 100644 --- a/README.md +++ b/README.md @@ -131,10 +131,8 @@ MONGODB_URI = "mongodb+srv://myDatabaseUser:D1fficultP%40ssw0rd@cluster0.example DATABASES["default"] = django_mongodb.parse_uri(MONGODB_URI) ``` -#### `django_mongodb.parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None)` +#### `django_mongodb.parse_uri(uri, test=None)` -- Use `conn_max_age` and `conn_health_checks` to configure [persistent database - connections](https://docs.djangoproject.com/en/stable/ref/databases/#persistent-database-connections). - Use `test` to provide a dictionary of [settings for test databases]( https://docs.djangoproject.com/en/stable/ref/settings/#test). diff --git a/django_mongodb/utils.py b/django_mongodb/utils.py index 40a1d1e2..5926075e 100644 --- a/django_mongodb/utils.py +++ b/django_mongodb/utils.py @@ -26,7 +26,7 @@ def check_django_compatability(): ) -def parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None): +def parse_uri(uri, test=None): """ Convert the given uri into a dictionary suitable for Django's DATABASES setting. @@ -51,8 +51,6 @@ def parse_uri(uri, conn_max_age=0, conn_health_checks=False, test=None): "USER": uri.get("username"), "PASSWORD": uri.get("password"), "OPTIONS": uri.get("options"), - "CONN_MAX_AGE": conn_max_age, - "CONN_HEALTH_CHECKS": conn_health_checks, } if test: settings_dict["TEST"] = test diff --git a/tests/utils_/test_parse_uri.py b/tests/utils_/test_parse_uri.py index b0d5a26d..e95529db 100644 --- a/tests/utils_/test_parse_uri.py +++ b/tests/utils_/test_parse_uri.py @@ -63,14 +63,6 @@ def test_localhosts_with_ports(self): self.assertEqual(settings_dict["HOST"], "localhost:27017,localhost:27018,localhost:27019") self.assertEqual(settings_dict["PORT"], None) - def test_conn_max_age(self): - settings_dict = parse_uri(URI, conn_max_age=600) - self.assertEqual(settings_dict["CONN_MAX_AGE"], 600) - - def test_conn_health_checks(self): - settings_dict = parse_uri(URI, conn_health_checks=True) - self.assertEqual(settings_dict["CONN_HEALTH_CHECKS"], True) - def test_test_kwarg(self): settings_dict = parse_uri(URI, test={"NAME": "test_db"}) self.assertEqual(settings_dict["TEST"]["NAME"], "test_db")