|
1 | | -from unittest.mock import MagicMock, patch |
| 1 | +from unittest.mock import patch |
2 | 2 |
|
3 | 3 | import pymongo |
4 | 4 | from django.test import SimpleTestCase |
|
9 | 9 |
|
10 | 10 |
|
11 | 11 | class ParseURITests(SimpleTestCase): |
12 | | - def setUp(self): |
13 | | - self.srv_record = MagicMock() |
14 | | - self.srv_record.target.to_text.return_value = "cluster0.example.mongodb.net" |
15 | | - self.patcher = patch("dns.resolver.resolve", return_value=[self.srv_record]) |
16 | | - self.mock_resolver = self.patcher.start() |
17 | | - self.addCleanup(self.patcher.stop) |
18 | | - |
19 | 12 | def test_simple_uri(self): |
20 | 13 | settings_dict = parse_uri("mongodb://cluster0.example.mongodb.net/myDatabase") |
21 | 14 | self.assertEqual(settings_dict["ENGINE"], "django_mongodb") |
@@ -66,15 +59,15 @@ def test_localhosts_with_ports(self): |
66 | 59 | self.assertEqual(settings_dict["PORT"], None) |
67 | 60 |
|
68 | 61 | def test_conn_max_age(self): |
69 | | - settings_dict = parse_uri(URI, conn_max_age=600) |
| 62 | + settings_dict = parse_uri("mongodb://localhost/myDatabase", conn_max_age=600) |
70 | 63 | self.assertEqual(settings_dict["CONN_MAX_AGE"], 600) |
71 | 64 |
|
72 | 65 | def test_conn_health_checks(self): |
73 | | - settings_dict = parse_uri(URI, conn_health_checks=True) |
| 66 | + settings_dict = parse_uri("mongodb://localhost/myDatabase", conn_health_checks=True) |
74 | 67 | self.assertEqual(settings_dict["CONN_HEALTH_CHECKS"], True) |
75 | 68 |
|
76 | 69 | def test_test_kwarg(self): |
77 | | - settings_dict = parse_uri(URI, test={"NAME": "test_db"}) |
| 70 | + settings_dict = parse_uri("mongodb://localhost/myDatabase", test={"NAME": "test_db"}) |
78 | 71 | self.assertEqual(settings_dict["TEST"]["NAME"], "test_db") |
79 | 72 |
|
80 | 73 | def test_invalid_credentials(self): |
|
0 commit comments