Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 async def test_put2(self):
     """test of mocked method put"""
     database = DatabaseMongo({})
     try:
         await database.put("test", {})
     except TypeError:
         pass
     else:
         raise Exception
Пример #6
0
 async def test_connect(self):
     """test the method connect"""
     database = DatabaseMongo({})
     try:
         await database.connect({})
     except NotImplementedError:
         raise Exception
     else:
         pass
Пример #7
0
 async def test_delete(self):
     """test of mocked method delete"""
     database = DatabaseMongo({})
     try:
         await database.delete("test")
     except TypeError:
         pass
     else:
         raise Exception
Пример #8
0
 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"])
Пример #9
0
def database(config):
    return DatabaseMongo(config)
Пример #10
0
def mocked_connect_database(mocker, config):
    mocker.patch("opsdroid.database.mongo.DatabaseMongo.connect",
                 return_value=mocker.AsyncMock())
    return DatabaseMongo(config)