Esempio n. 1
0
 def setUp(self):
     try:
         self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN, MDN)
         self.calcMongo = CalcMongo()
     except ConnectionFailure as e:
         pass
Esempio n. 2
0
class TestMongoStatistic(unittest.TestCase):
    def setUp(self):
        self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                           FC_DN, MDN)
        self.__simpleNormal = SimpleNormalization()
        self.__fileSourceCustom = FileSourceCustom()
        self.__fileBlockSource = FileBlockSource()
        self.__calcMongo = CalcMongo()
        self.__mongoStatistics = MongoStatistic(self.__mongoUtils)
        self.__dirPath = os.path.abspath(os.curdir)

    def tearDown(self):
        try:
            self.__mongoUtils.deleteMergeDict()
        except DataNotFound:
            pass

    def testMakeDocStatisticCustomUtf8(self):
        filePath = os.path.join(self.__dirPath,
                                "resources/test_mongo_index_utf8")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource,
                                                      self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatisticCustomWin1251(self):
        filePath = os.path.join(self.__dirPath,
                                "resources/test_mongo_index_win1251")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource,
                                                      self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatisticCustomWin866(self):
        filePath = os.path.join(self.__dirPath,
                                "resources/test_mongo_index_win866")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource,
                                                      self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatistic(self):
        data = "Проверка проверка сохранения индекса. Check save statistic"
        self.__mongoStatistics.makeDocStatistic("test_source_name", 1234, data,
                                                self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testAddMoreStatistics(self):
        filePath = os.path.join(self.__dirPath,
                                "resources/test_mongo_index_utf8")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource,
                                                      self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()
        self.__mongoUtils.addMoreStatistics(self.__calcMongo)
Esempio n. 3
0
 def setUp(self):
     self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                        FC_DN, MDN)
     self.__simpleNormal = SimpleNormalization()
     self.__fileSourceCustom = FileSourceCustom()
     self.__fileBlockSource = FileBlockSource()
     self.__calcMongo = CalcMongo()
     self.__mongoStatistics = MongoStatistic(self.__mongoUtils)
     self.__dirPath = os.path.abspath(os.curdir)
Esempio n. 4
0
class TestMongoStatistic(unittest.TestCase):

    def setUp(self):
        self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
        self.__simpleNormal = SimpleNormalization()
        self.__fileSourceCustom = FileSourceCustom()
        self.__fileBlockSource = FileBlockSource()
        self.__calcMongo = CalcMongo()
        self.__mongoStatistics = MongoStatistic(self.__mongoUtils)
        self.__dirPath = os.path.abspath(os.curdir)

    def tearDown(self):
        try:
            self.__mongoUtils.deleteMergeDict()
        except DataNotFound:
            pass

    def testMakeDocStatisticCustomUtf8(self):
        filePath = os.path.join(self.__dirPath, "resources/test_mongo_index_utf8")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource, self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatisticCustomWin1251(self):
        filePath = os.path.join(self.__dirPath, "resources/test_mongo_index_win1251")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource, self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatisticCustomWin866(self):
        filePath = os.path.join(self.__dirPath, "resources/test_mongo_index_win866")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource, self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testMakeDocStatistic(self):
        data = "Проверка проверка сохранения индекса. Check save statistic"
        self.__mongoStatistics.makeDocStatistic("test_source_name", 1234, data, self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()

    def testAddMoreStatistics(self):
        filePath = os.path.join(self.__dirPath, "resources/test_mongo_index_utf8")
        self.__fileSourceCustom.custom = filePath
        self.__mongoStatistics.makeDocStatisticCustom(self.__fileBlockSource, self.__fileSourceCustom,
                                                      self.__simpleNormal)
        self.__mongoStatistics.makeTotalStatistic()
        self.__mongoUtils.addMoreStatistics(self.__calcMongo)
Esempio n. 5
0
 def setUp(self):
     date_now = datetime.datetime.now()
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN)
     self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                        FC_DN, MDN)
     self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {
         "the": 1,
         "test": 2
     }, "utf-8", date_now)
     self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {
         "the": 100,
         "object": 2
     }, 'utf-8', date_now)
     self.__mongoUtils.mergeDicts()
Esempio n. 6
0
 def setUp(self):
     date_now = datetime.datetime.now()
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
     self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
     self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {"the": 1, "test": 2}, "utf-8", date_now)
     self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {"the": 100, "object": 2}, 'utf-8', date_now)
     self.__mongoUtils.mergeDicts()
Esempio n. 7
0
 def setUp(self):
     self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
     self.__simpleNormal = SimpleNormalization()
     self.__fileSourceCustom = FileSourceCustom()
     self.__fileBlockSource = FileBlockSource()
     self.__calcMongo = CalcMongo()
     self.__mongoStatistics = MongoStatistic(self.__mongoUtils)
     self.__dirPath = os.path.abspath(os.curdir)
Esempio n. 8
0
 def setUp(self):
     self.__dirPath = os.path.abspath(os.curdir)
     firstPath = os.path.join(self.__dirPath, "resources/first")
     secondPath = os.path.join(self.__dirPath, "resources/second")
     self.__mongoUtils = MongoSaveRetrievalUtils(HOST, PORT, USR, PWD, DB,
                                                 FC_N, FC_DN, MDN)
     self.__mongoUtilsTypeError = MongoSaveUtils(HOST, PORT, USR, PWD, DB,
                                                 FC_N, FC_DN, MDN)
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN)
     self.__smN = SimpleNormalization()
     self.__scc = FSSourceCustomCallback()
     self.__rFS = ReaderNameFS([firstPath, secondPath])
     self.__fsWorker = DataSourceWorkerFS()
Esempio n. 9
0
class TestMongoSaveUtils(unittest.TestCase):
    def setUp(self):
        try:
            self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                               FC_DN, MDN)
            self.calcMongo = CalcMongo()
        except ConnectionFailure as e:
            pass

    def tearDown(self):
        try:
            self.__mongoUtils.deleteMergeDict()
        except DataNotFound:
            pass

    def testConnection(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is fail")

    def testGetMergeDictID(self):
        self.assertIsNotNone(self.__mongoUtils.getMergeDictID(),
                             "fail to get merge dict ID")

    def testSaveAddDict(self):
        insertID = self.__mongoUtils.saveDict("test_dict", "utf-8", 1234, {
            "the": 1,
            "test": 2
        }, "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.add2Dict(insertID, {"plus": 1, "test": 2})
        self.__mongoUtils.deleteMergeDict()

    def testMergeDicts(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is ok")
        insertID = self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {
            "the": 1,
            "test": 2
        }, "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)

        insertID = self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {
            "the": 100,
            "object": 2
        }, 'utf-8', datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.mergeDicts()

    def testAddMoreStatistics(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is ok")
        insertID = self.__mongoUtils.saveDict("test_dict3", "utf-8", 1234, {
            "the": 1,
            "test": 2
        }, "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)

        insertID = self.__mongoUtils.saveDict("test_dict4", "utf-8", 4321, {
            "the": 100,
            "object": 1
        }, 'utf-8', datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.mergeDicts()
        self.__mongoUtils.addMoreStatistics(self.calcMongo)

    def testAddMoreStatisticsException(self):
        self.assertRaises(ParamError, self.__mongoUtils.addMoreStatistics,
                          None)
        self.assertRaises(ParamError, self.__mongoUtils.addMoreStatistics,
                          1234)
        self.__mongoUtils.deleteMergeDict()
        self.assertRaises(DataNotFound, self.__mongoUtils.addMoreStatistics,
                          self.calcMongo)
Esempio n. 10
0
 def setUp(self):
     try:
         self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
         self.calcMongo = CalcMongo()
     except ConnectionFailure as e:
         pass
Esempio n. 11
0
class TestMongoSaveUtils(unittest.TestCase):

    def setUp(self):
        try:
            self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
            self.calcMongo = CalcMongo()
        except ConnectionFailure as e:
            pass

    def tearDown(self):
        try:
            self.__mongoUtils.deleteMergeDict()
        except DataNotFound:
            pass

    def testConnection(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is fail")

    def testGetMergeDictID(self):
        self.assertIsNotNone(self.__mongoUtils.getMergeDictID(), "fail to get merge dict ID")

    def testSaveAddDict(self):
        insertID = self.__mongoUtils.saveDict("test_dict", "utf-8", 1234, {"the": 1, "test": 2},
                                              "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.add2Dict(insertID, {"plus": 1, "test": 2})
        self.__mongoUtils.deleteMergeDict()

    def testMergeDicts(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is ok")
        insertID = self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {"the": 1, "test": 2},
                                              "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)

        insertID = self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {"the": 100, "object": 2},
                                              'utf-8', datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.mergeDicts()

    def testAddMoreStatistics(self):
        self.assertIsNotNone(self.__mongoUtils, "connection is ok")
        insertID = self.__mongoUtils.saveDict("test_dict3", "utf-8", 1234, {"the": 1, "test": 2},
                                              "utf-8", datetime.datetime.now())
        self.assertIsNotNone(insertID)

        insertID = self.__mongoUtils.saveDict("test_dict4", "utf-8", 4321, {"the": 100, "object": 1},
                                              'utf-8', datetime.datetime.now())
        self.assertIsNotNone(insertID)
        self.__mongoUtils.mergeDicts()
        self.__mongoUtils.addMoreStatistics(self.calcMongo)

    def testAddMoreStatisticsException(self):
        self.assertRaises(ParamError, self.__mongoUtils.addMoreStatistics, None)
        self.assertRaises(ParamError, self.__mongoUtils.addMoreStatistics, 1234)
        self.__mongoUtils.deleteMergeDict()
        self.assertRaises(DataNotFound, self.__mongoUtils.addMoreStatistics, self.calcMongo)
Esempio n. 12
0
class TestMongoReadUtils(unittest.TestCase):
    def setUp(self):
        date_now = datetime.datetime.now()
        self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                               FC_DN)
        self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                           FC_DN, MDN)
        self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {
            "the": 1,
            "test": 2
        }, "utf-8", date_now)
        self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {
            "the": 100,
            "object": 2
        }, 'utf-8', date_now)
        self.__mongoUtils.mergeDicts()

    def tearDown(self):
        self.__mongoUtils.deleteMergeDict()

    def testGetDict(self):
        self.assertIsNotNone(
            self.__mongoReadUtils.getDict(self.__mongoUtils.getMergeDictID()),
            "dict not found")

    def testGetSubDicts(self):
        for itemSubDicts in self.__mongoReadUtils.getSubDicts(
                self.__mongoUtils.getMergeDictID()):
            self.assertIsNotNone(itemSubDicts, "sub dict get exception")

    def testGetDictData(self):
        for itemDictData in self.__mongoReadUtils.getDictData(
                self.__mongoUtils.getMergeDictID()):
            self.assertIsNotNone(itemDictData, "dict data is not found")
Esempio n. 13
0
class TestMongoReadUtils(unittest.TestCase):

    def setUp(self):
        date_now = datetime.datetime.now()
        self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN)
        self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
        self.__mongoUtils.saveDict("test_dict1", "utf-8", 1234, {"the": 1, "test": 2}, "utf-8", date_now)
        self.__mongoUtils.saveDict("test_dict2", "utf-8", 4321, {"the": 100, "object": 2}, 'utf-8', date_now)
        self.__mongoUtils.mergeDicts()

    def tearDown(self):
        self.__mongoUtils.deleteMergeDict()

    def testGetDict(self):
        self.assertIsNotNone(self.__mongoReadUtils.getDict(self.__mongoUtils.getMergeDictID()), "dict not found")

    def testGetSubDicts(self):
        for itemSubDicts in self.__mongoReadUtils.getSubDicts(self.__mongoUtils.getMergeDictID()):
            self.assertIsNotNone(itemSubDicts, "sub dict get exception")

    def testGetDictData(self):
        for itemDictData in self.__mongoReadUtils.getDictData(self.__mongoUtils.getMergeDictID()):
            self.assertIsNotNone(itemDictData, "dict data is not found")