async def test_get2(self): """test of mocked method get""" database = DatabaseMongo({}) database.database = {} database.database['test'] = DatabaseMongoTest({}) try: await database.get("test") except TypeError: pass else: raise Exception
async def test_put(self): """test of mocked put""" database = DatabaseMongo({}) database.database = {} database.database['test'] = DatabaseMongoTest({}) try: await database.put("test", {"_id": "0", "key": "value"}) except TypeError: try: await database.put("test", {}) except NotImplementedError: raise Exception else: pass else: raise Exception
async def test_put(self): """test of mocked put""" database = DatabaseMongo({}) database.database = {} database.database['test'] = DatabaseMongoTest({}) try: await database.put("test", {"_id":"0" , "key":"value"}) except TypeError: try: await database.put("test", {}) except NotImplementedError: raise Exception else: pass else: raise Exception
async def test_put2(self): """test of mocked method put""" database = DatabaseMongo({}) try: await database.put("test", {}) except TypeError: pass else: raise Exception
async def test_connect(self): """test the method connect""" database = DatabaseMongo({}) try: await database.connect({}) except NotImplementedError: raise Exception else: pass
async def test_delete(self): """test of mocked method delete""" database = DatabaseMongo({}) try: await database.delete("test") except TypeError: pass else: raise Exception
def test_init(self): """Initialization fo mock database""" config = {"example_item": "test"} database = DatabaseMongo(config) self.assertEqual("mongo", database.name) self.assertEqual("test", database.config["example_item"])
def database(config): return DatabaseMongo(config)
def mocked_connect_database(mocker, config): mocker.patch("opsdroid.database.mongo.DatabaseMongo.connect", return_value=mocker.AsyncMock()) return DatabaseMongo(config)