class TestSimpleNormalization(unittest.TestCase):

    def setUp(self):
        self.__simpleNormalization = SimpleNormalization()
        self.__dirPath = os.path.abspath(os.curdir)
        self.__normalizeWords = ["thi", "test", "file", "encod", "проверк", "определен", "кодировк", "фа"]

    def testNormalizeText(self):
        filePath = os.path.join(self.__dirPath, "resources/test_encode_utf8")
        with open(filePath) as utf8File:
            words = self.__simpleNormalization.normalizeText(utf8File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_utf8")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win1251")
        with open(filePath) as win1251File:
            words = self.__simpleNormalization.normalizeText(win1251File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_win1251")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win866")
        with open(filePath) as win866File:
            words = self.__simpleNormalization.normalizeText(win866File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_win866")

    def testNormalizeTextParamError(self):
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText, None)
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText, "")
class TestSimpleNormalization(unittest.TestCase):
    def setUp(self):
        self.__simpleNormalization = SimpleNormalization()
        self.__dirPath = os.path.abspath(os.curdir)
        self.__normalizeWords = [
            "thi", "test", "file", "encod", "проверк", "определен", "кодировк",
            "фа"
        ]

    def testNormalizeText(self):
        filePath = os.path.join(self.__dirPath, "resources/test_encode_utf8")
        with open(filePath) as utf8File:
            words = self.__simpleNormalization.normalizeText(utf8File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_utf8")

        filePath = os.path.join(self.__dirPath,
                                "resources/test_encode_win1251")
        with open(filePath) as win1251File:
            words = self.__simpleNormalization.normalizeText(
                win1251File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_win1251")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win866")
        with open(filePath) as win866File:
            words = self.__simpleNormalization.normalizeText(win866File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_win866")

    def testNormalizeTextParamError(self):
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText,
                          None)
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText,
                          "")