Пример #1
0
    def test_serialize(self):
        db = MongoDBService()
        m = ModelExample("test", "test_serialize")

        name = db.get_collection_name(m)
        dic = db.object_to_dict(m)

        self.assertTrue("model_example", name)
        self.assertTrue(m.title, dic["title"])
        self.assertTrue(m.date, dic["date"])
        self.assertFalse("_private" in dic)
        self.assertFalse("method" in dic)
Пример #2
0
 def get_db(cls, env=None):
     from kanaria.core.service.db import MongoDBService
     env = env if env else Environment()
     return MongoDBService(env.database_uri)
Пример #3
0
 def test_get_collection(self):
     db = MongoDBService()
     collection = db.get_collection(ModelExample)
     self.assertTrue(collection)