def get_platform(self, platform_id): """Get a platform :param platform_id: The uuid of a platform :returns: an object of type platform containing the requested platform """ mongo_result = self.__db.platforms.find_one({"_id": ObjectId(platform_id)}) return Platform.from_mongo_result(mongo_result)
def test_from_mongo_result_performs_mapping(self): """Initialise the mapper :param mongo_result: A MongoDB result. The following fields can currently be mapped: * _id * _Platform__name * _Platform__description """ d = {"_id": "id", "_Platform__name": "name", "_Platform__description": "description"} p = Platform.from_mongo_result(d) self.assertEqual(d["_id"], p.id) self.assertEqual(d["_Platform__name"], p.name) self.assertEqual(d["_Platform__description"], p.description)
def get_platforms(self): """Get a list of platforms :returns: A list of type Platform of all stored platforms """ result = self.__db.platforms.find().sort("_Platform__name") return list(map(lambda p: Platform.from_mongo_result(p), result))