|
1 | 1 | from unittest.mock import patch |
2 | 2 |
|
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | | -from django.db import connection |
| 4 | +from django.db import NotSupportedError, connection |
5 | 5 | from django.db.backends.signals import connection_created |
6 | 6 | from django.test import SimpleTestCase, TestCase |
7 | 7 |
|
@@ -146,3 +146,26 @@ def receiver(sender, connection, **kwargs): # noqa: ARG001 |
146 | 146 | data.clear() |
147 | 147 | connection.connect() |
148 | 148 | self.assertEqual(data, {}) |
| 149 | + |
| 150 | + |
| 151 | +class CursorTests(TestCase): |
| 152 | + def test_callproc(self): |
| 153 | + msg = "MongoDB does not support cursor.callproc()." |
| 154 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 155 | + cursor.callproc("...") |
| 156 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 157 | + cursor.callproc("...", []) |
| 158 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 159 | + cursor.callproc("...", [], []) |
| 160 | + |
| 161 | + def test_execute(self): |
| 162 | + msg = "MongoDB does not support cursor.execute()." |
| 163 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 164 | + cursor.execute("...") |
| 165 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 166 | + cursor.execute("...", []) |
| 167 | + |
| 168 | + def test_executemany(self): |
| 169 | + msg = "MongoDB does not support cursor.executemany()." |
| 170 | + with self.assertRaisesMessage(NotSupportedError, msg), connection.cursor() as cursor: |
| 171 | + cursor.executemany("...", []) |
0 commit comments