Skip to content

Commit 88c1cde

Browse files
committed
Use DatabaseFeatures.disallowed_simple_test_case_connection_methods
(new in Django 6.1)
1 parent 71a91d1 commit 88c1cde

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

django_mongodb_backend/features.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class DatabaseFeatures(GISFeatures, BaseDatabaseFeatures):
5858
supports_unspecified_pk = True
5959
uses_savepoints = False
6060

61+
disallowed_simple_test_case_connection_methods = [
62+
("connect", "connections"),
63+
("get_collection", "queries"),
64+
("temporary_connection", "connections"),
65+
]
66+
6167
_django_test_expected_failures = {
6268
# $concat only supports strings, not int
6369
"db_functions.text.test_concat.ConcatTests.test_concat_non_str",
@@ -93,6 +99,7 @@ class DatabaseFeatures(GISFeatures, BaseDatabaseFeatures):
9399
# Connection creation doesn't follow the usual Django API.
94100
"backends.tests.ThreadTests.test_pass_connection_between_threads",
95101
"backends.tests.ThreadTests.test_default_connection_thread_local",
102+
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
96103
# Object of type ObjectId is not JSON serializable.
97104
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
98105
# GenericRelation.value_to_string() assumes integer pk.
@@ -423,15 +430,6 @@ def django_test_expected_failures(self):
423430
"servers.test_liveserverthread.LiveServerThreadTest.test_closes_connections",
424431
"servers.tests.LiveServerTestCloseConnectionTest.test_closes_connections",
425432
},
426-
"Disallowed query protection doesn't work on MongoDB.": {
427-
# Because this backend doesn't use cursor(), chunked_cursor(), etc.
428-
# https://github.com/django/django/blob/045110ff3089aefd9c3e65c707df465bacfed986/django/test/testcases.py#L195-L206
429-
"test_utils.test_testcase.TestTestCase.test_disallowed_database_queries",
430-
"test_utils.test_transactiontestcase.DisallowedDatabaseQueriesTests.test_disallowed_database_queries",
431-
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_database_chunked_cursor_queries",
432-
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_database_queries",
433-
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
434-
},
435433
"search lookup not supported on non-Atlas until MongoDB 8.2.": {
436434
"expressions.tests.BasicExpressionsTests.test_lookups_subquery",
437435
},

0 commit comments

Comments
 (0)