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)
class TestFileBlockSource(unittest.TestCase): def setUp(self): self.__fileBlockSource = FileBlockSource(blockSize=8) self.__dirPath = os.path.abspath(os.curdir) def testGetSource(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) self.assertIsNotNone(source, "not open source") self.__fileBlockSource.closeSource(source) def testGetSourceThrowIOError(self): filePath = os.path.join(self.__dirPath, "resources/not_exist_file") self.assertRaises(IOError, self.__fileBlockSource.openSource, filePath) def testRead(self): filePath = os.path.join(self.__dirPath, "resources/test_read_file") source = self.__fileBlockSource.openSource(filePath) for block in self.__fileBlockSource.read(source): self.assertIsNotNone(block) self.__fileBlockSource.closeSource(source)
def setUp(self): self.__fileBlockSource = FileBlockSource(blockSize=8) self.__dirPath = os.path.abspath(os.curdir)