10
10
11
11
class MongoParseURITests (SimpleTestCase ):
12
12
"""
13
- Test django_mongodb.parse (uri) function
13
+ Test django_mongodb.parse_uri (uri) function
14
14
"""
15
15
16
16
def setUp (self ):
@@ -22,14 +22,16 @@ def setUp(self):
22
22
23
23
@patch ("dns.resolver.resolve" )
24
24
def test_uri (self , mock_resolver ):
25
- settings_dict = django_mongodb .parse ("mongodb://cluster0.example.mongodb.net/myDatabase" )
25
+ settings_dict = django_mongodb .parse_uri (
26
+ "mongodb://cluster0.example.mongodb.net/myDatabase"
27
+ )
26
28
self .assertEqual (settings_dict ["ENGINE" ], "django_mongodb" )
27
29
self .assertEqual (settings_dict ["NAME" ], "myDatabase" )
28
30
self .assertEqual (settings_dict ["HOST" ], "cluster0.example.mongodb.net" )
29
31
30
32
@patch ("dns.resolver.resolve" )
31
33
def test_srv_uri_with_options (self , mock_resolver ):
32
- settings_dict = django_mongodb .parse (URI )
34
+ settings_dict = django_mongodb .parse_uri (URI )
33
35
self .assertEqual (settings_dict ["ENGINE" ], "django_mongodb" )
34
36
self .assertEqual (settings_dict ["NAME" ], "myDatabase" )
35
37
self .assertEqual (settings_dict ["HOST" ], "mongodb+srv://cluster0.example.mongodb.net" )
@@ -41,41 +43,41 @@ def test_srv_uri_with_options(self, mock_resolver):
41
43
)
42
44
43
45
def test_localhost (self ):
44
- settings_dict = django_mongodb .parse ("mongodb://localhost/myDatabase" )
46
+ settings_dict = django_mongodb .parse_uri ("mongodb://localhost/myDatabase" )
45
47
self .assertEqual (settings_dict ["ENGINE" ], "django_mongodb" )
46
48
self .assertEqual (settings_dict ["NAME" ], "myDatabase" )
47
49
self .assertEqual (settings_dict ["HOST" ], "localhost" )
48
50
49
51
def test_localhost_bad_credentials (self ):
50
52
with self .assertRaises (pymongo .errors .InvalidURI ):
51
- django_mongodb .parse ("mongodb://:@localhost/myDatabase" )
53
+ django_mongodb .parse_uri ("mongodb://:@localhost/myDatabase" )
52
54
53
55
@patch ("dns.resolver.resolve" )
54
56
def test_engine_kwarg (self , mock_resolver ):
55
- settings_dict = django_mongodb .parse (URI , engine = "some_other_engine" )
57
+ settings_dict = django_mongodb .parse_uri (URI , engine = "some_other_engine" )
56
58
self .assertEqual (settings_dict ["ENGINE" ], "some_other_engine" )
57
59
58
60
@patch ("dns.resolver.resolve" )
59
61
def test_conn_max_age_kwarg (self , mock_resolver ):
60
- settings_dict = django_mongodb .parse (URI , conn_max_age = 600 )
62
+ settings_dict = django_mongodb .parse_uri (URI , conn_max_age = 600 )
61
63
self .assertEqual (settings_dict ["CONN_MAX_AGE" ], 600 )
62
64
63
65
@patch ("dns.resolver.resolve" )
64
66
def test_conn_health_checks_kwarg (self , mock_resolver ):
65
- settings_dict = django_mongodb .parse (URI , conn_health_checks = True )
67
+ settings_dict = django_mongodb .parse_uri (URI , conn_health_checks = True )
66
68
self .assertEqual (settings_dict ["CONN_HEALTH_CHECKS" ], True )
67
69
68
70
@patch ("dns.resolver.resolve" )
69
71
def test_ssl_require_kwarg (self , mock_resolver ):
70
- settings_dict = django_mongodb .parse (URI , ssl_require = True )
72
+ settings_dict = django_mongodb .parse_uri (URI , ssl_require = True )
71
73
self .assertEqual (settings_dict ["SSL_REQUIRE" ], True )
72
74
73
75
@patch ("dns.resolver.resolve" )
74
76
def test_test_kwarg (self , mock_resolver ):
75
- settings_dict = django_mongodb .parse (URI , test = {"NAME" : "test_db" })
77
+ settings_dict = django_mongodb .parse_uri (URI , test = {"NAME" : "test_db" })
76
78
self .assertEqual (settings_dict ["TEST" ]["NAME" ], "test_db" )
77
79
78
80
@patch ("dns.resolver.resolve" )
79
81
def test_uri_no_prefix (self , mock_resolver ):
80
82
with self .assertRaises (pymongo .errors .InvalidURI ):
81
- django_mongodb .parse ("cluster0.example.mongodb.net/myDatabase" )
83
+ django_mongodb .parse_uri ("cluster0.example.mongodb.net/myDatabase" )
0 commit comments