Skip to content

Commit 05ba445

Browse files
committed
test non-None PORT
1 parent 05df78c commit 05ba445

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/utils_/test_parse_uri.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ def test_localhost(self):
4949
self.assertEqual(settings_dict["NAME"], "myDatabase")
5050
self.assertEqual(settings_dict["HOST"], "localhost")
5151

52+
def test_localhost_with_port(self):
53+
settings_dict = parse_uri("mongodb://localhost/myDatabase")
54+
self.assertEqual(settings_dict["ENGINE"], "django_mongodb")
55+
self.assertEqual(settings_dict["NAME"], "myDatabase")
56+
self.assertEqual(settings_dict["HOST"], "localhost")
57+
self.assertEqual(settings_dict["PORT"], 27017)
58+
5259
def test_localhosts_with_ports(self):
5360
settings_dict = parse_uri(
5461
"mongodb://localhost:27017,localhost:27018,localhost:27019/myDatabase"
5562
)
5663
self.assertEqual(settings_dict["ENGINE"], "django_mongodb")
5764
self.assertEqual(settings_dict["NAME"], "myDatabase")
5865
self.assertEqual(settings_dict["HOST"], "localhost:27017,localhost:27018,localhost:27019")
66+
self.assertEqual(settings_dict["PORT"], None)
5967

6068
@patch("dns.resolver.resolve")
6169
def test_conn_max_age(self, mock_resolver):

0 commit comments

Comments
 (0)