Example #1
0
 def testSearchFilename(self):
     mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
     customDict = {"result_cn": "rcn"}
     mdID = self.mongoSaveUtils.getMergeDictID()
     findObject = mongoSearch.searchFilename([TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)
     self.assertIsNotNone(findObject, "findObject == None")
     mongoSearch.removeSearchData(findObject)
Example #2
0
 def testSearchData(self):
     mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
     customDict = {"result_cn": "rcd"}
     mdID = self.mongoSaveUtils.getMergeDictID()
     findObject = mongoSearch.searchData([None, ["the"]], customDict, mdID)
     self.assertIsNotNone(findObject, "findObject == None")
     mongoSearch.removeSearchData(findObject)
Example #3
0
 def testSearchData(self):
     mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                             FC_DN)
     customDict = {"result_cn": "rcd"}
     mdID = self.mongoSaveUtils.getMergeDictID()
     findObject = mongoSearch.searchData([None, ["the"]], customDict, mdID)
     self.assertIsNotNone(findObject, "findObject == None")
     mongoSearch.removeSearchData(findObject)
Example #4
0
 def testSearchFilename(self):
     mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                             FC_DN)
     customDict = {"result_cn": "rcn"}
     mdID = self.mongoSaveUtils.getMergeDictID()
     findObject = mongoSearch.searchFilename(
         [TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)
     self.assertIsNotNone(findObject, "findObject == None")
     mongoSearch.removeSearchData(findObject)
Example #5
0
    def testGetSearchDataException(self):
        mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
        customDict = {"result_cn": "rcn"}
        customDictData = {"is_lazy": False}
        mdID = self.mongoSaveUtils.getMergeDictID()
        findObject = mongoSearch.searchFilename([TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)

        self.assertRaises(ParamError, mongoSearch.getSearchData, None, customDictData)
        self.assertRaises(ParamError, mongoSearch.getSearchData, findObject, None)
        self.assertRaises(TypeError, mongoSearch.getSearchData, "string", customDictData)
        self.assertRaises(TypeError, mongoSearch.getSearchData, findObject, "string")
        self.assertRaises(KeyError, mongoSearch.getSearchData, findObject, {"bb": 40})

        mongoSearch.removeSearchData(findObject)
Example #6
0
    def testSearchData(self):
        mongoSearchUtils = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB,
                                                     FC_N, FC_DN)
        cd = {"result_cn": "rcd"}  # customDict
        cdd = {"is_lazy": False}  # customDictData
        mdID = self.mongoSaveUtils.getMergeDictID()

        mongoSearch = MongoSearch(mongoSearchUtils)
        self.assertIsNotNone(
            mongoSearch.searchData([None, ["the"]], cd, cdd, mdID))
        mongoSearch.removeFindObject()
Example #7
0
    def testGetSearchDataException(self):
        mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                                FC_DN)
        customDict = {"result_cn": "rcn"}
        customDictData = {"is_lazy": False}
        mdID = self.mongoSaveUtils.getMergeDictID()
        findObject = mongoSearch.searchFilename(
            [TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)

        self.assertRaises(ParamError, mongoSearch.getSearchData, None,
                          customDictData)
        self.assertRaises(ParamError, mongoSearch.getSearchData, findObject,
                          None)
        self.assertRaises(TypeError, mongoSearch.getSearchData, "string",
                          customDictData)
        self.assertRaises(TypeError, mongoSearch.getSearchData, findObject,
                          "string")
        self.assertRaises(KeyError, mongoSearch.getSearchData, findObject,
                          {"bb": 40})

        mongoSearch.removeSearchData(findObject)
Example #8
0
 def testSearchDataException(self):
     mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                             FC_DN)
     customDict = {"result_cn": "rcd"}
     mdID = self.mongoSaveUtils.getMergeDictID()
     self.assertRaises(ParamError, mongoSearch.searchData, None, customDict,
                       mdID)
     self.assertRaises(ParamError, mongoSearch.searchData,
                       [None, [["doc"], ["doc"]]], None, mdID)
     self.assertRaises(ParamError, mongoSearch.searchData,
                       [None, [["doc"], ["doc"]]], customDict, None)
     self.assertRaises(TypeError, mongoSearch.searchData, "string",
                       customDict, mdID)
     self.assertRaises(TypeError, mongoSearch.searchData,
                       [None, [["doc"], ["doc"]]], "string", mdID)
     self.assertRaises(KeyError, mongoSearch.searchData,
                       [None, [["doc"], ["doc"]]], {"aa": 10}, mdID)
Example #9
0
    def testGetSearchData(self):
        mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
        customDict = {"result_cn": "rcn"}
        customDictData = {"is_lazy": False}
        mdID = self.mongoSaveUtils.getMergeDictID()

        # поиск по именам источников
        # логический запрос
        findObject = mongoSearch.searchFilename([TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
            self.assertEqual(int(doc["value"]["count"]), 2, "count != 2")

        # запрос точного совпадения
        customDictData["is_lazy"] = False
        findObject = mongoSearch.searchFilename([TYPE_Q_EXACT, "some doc~"], customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")

        mongoSearch.removeSearchData(findObject)

        # поиск по данным из источника
        customDict["result_cn"] = "rcd"
        customDictData["is_lazy"] = False
        findObject = mongoSearch.searchData([None, ["the"]], customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
            self.assertEqual(int(doc["value"]["count"]), 1, "count != 1")

        mongoSearch.removeSearchData(findObject)
Example #10
0
    def testGetSearchData(self):
        mongoSearch = MongoSearchRetrievalUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                                FC_DN)
        customDict = {"result_cn": "rcn"}
        customDictData = {"is_lazy": False}
        mdID = self.mongoSaveUtils.getMergeDictID()

        # поиск по именам источников
        # логический запрос
        findObject = mongoSearch.searchFilename(
            [TYPE_Q_LOGIC, [["doc"], ["doc"]]], customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
            self.assertEqual(int(doc["value"]["count"]), 2, "count != 2")

        # запрос точного совпадения
        customDictData["is_lazy"] = False
        findObject = mongoSearch.searchFilename([TYPE_Q_EXACT, "some doc~"],
                                                customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")

        mongoSearch.removeSearchData(findObject)

        # поиск по данным из источника
        customDict["result_cn"] = "rcd"
        customDictData["is_lazy"] = False
        findObject = mongoSearch.searchData([None, ["the"]], customDict, mdID)
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
        customDictData["is_lazy"] = True
        result = mongoSearch.getSearchData(findObject, customDictData)
        for doc in result:
            self.assertIsNotNone(doc, "map-reduce doc == None")
            self.assertEqual(int(doc["value"]["count"]), 1, "count != 1")

        mongoSearch.removeSearchData(findObject)