File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ def _create_connection(conn_settings):
9292 elif "://" in conn .get ('host' , '' ):
9393 uri_dict = uri_parser .parse_uri (conn ['host' ])
9494 conn ['db' ] = uri_dict ['database' ]
95+ if conn ['db' ] is None :
96+ raise ValueError ('Mongo host URI must contain database name' )
9597
9698 return mongoengine .connect (conn .pop ('db' , 'test' ), ** conn )
9799
Original file line number Diff line number Diff line change @@ -32,5 +32,11 @@ def test_parse_uri_if_testing_not_true(self):
3232
3333 self .assertRaises (InvalidURI , MongoEngine , self .app )
3434
35+ def test_parse_uri_without_database_name (self ):
36+ self .app .config ['TESTING' ] = False
37+ self .app .config ['MONGODB_HOST' ] = 'mongodb://localhost'
38+
39+ self .assertRaises (ValueError , MongoEngine , self .app )
40+
3541if __name__ == '__main__' :
3642 unittest .main ()
You can’t perform that action at this time.
0 commit comments