

def test__getting_default_database_valid(self):

    def gddb(uri):
        client = mongomock.MongoClient(uri)
        return (client, client.get_default_database())
    (c, db) = gddb('mongodb://host1/foo')
    self.assertIsNotNone(db)
    self.assertIsInstance(db, Database)
    self.assertIs(db.client, c)
    self.assertIs(db, c['foo'])
    (c, db) = gddb('mongodb://host1/bar')
    self.assertIs(db, c['bar'])
    (c, db) = gddb('mongodb://a%00lice:f%00oo@127.0.0.1/t%00est')
    self.assertIs(db, c['t\x00est'])
    (c, db) = gddb('mongodb://bob:bar@[::1]:27018/admin')
    self.assertIs(db, c['admin'])
    (c, db) = gddb('mongodb://%24am:f%3Azzb%40zz@127.0.0.1/admin%3F?authMechanism=MONGODB-CR')
    self.assertIs(db, c['admin?'])

dataset/ETHPy150Open vmalloc/mongomock/tests/test__mongomock.py DatabaseGettingTest.test__getting_default_database_valid/original