Пример #1
0
 def testGetSetOfPossiblePhrasesForDigit(self):
     number = "2"
     expectedList = ["A", "B", "C"]
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getPossiblePhraseforDigit(number,
                                            alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #2
0
 def testCheckIfDigitDoesNotHaveReplacements(self):
     number = "!"
     expectedList = []
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getPossiblePhraseforDigit(number,
                                            alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #3
0
 def testGetListOfPossiblePhrasesForNumberWithPunctuations(self):
     number = "2!3?"
     expectedList = ['AD', 'AE', 'AF', 'BD', 'BE', 'BF', 'CD', 'CE', 'CF']
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getAlphaPhrasesForEachNumber(number,
                                               alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #4
0
def getInputDataOfDictionary(pointer_to_dictionary):
    if (pointer_to_dictionary is not False):  # if file exist
        alphaPhrasesFromDictionary = getDictionaryData(
            pointer_to_dictionary)  # getting the alpha phrases of dictionary
        return alphaPhrasesFromDictionary

    else:
        print("Error: dictionary file does not exist."
              )  # printing the message if the file does not exist
        return []
Пример #5
0
 def testNotHaveAlphaPhraseReplacementForNumberDueToTwoConsecutiveUnchangedDigits(
         self):
     number = "2310"
     expectedList = []
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getAlphaPhrasesForEachNumber(number,
                                               alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #6
0
 def testCanHaveAlphaPhraseReplacementForNumber(self):
     number = "231"
     expectedList = [
         'AD1', 'AE1', 'AF1', 'BD1', 'BE1', 'BF1', 'CD1', 'CE1', 'CF1'
     ]
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getAlphaPhrasesForEachNumber(number,
                                               alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #7
0
 def testGetListOfPossiblePhrasesForNumberWithHyphen(self):
     number = "2-3"
     expectedList = [
         'A-D', 'A-E', 'A-F', 'B-D', 'B-E', 'B-F', 'C-D', 'C-E', 'C-F'
     ]
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getAlphaPhrasesForEachNumber(number,
                                               alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList, actualList)
Пример #8
0
 def testCanHaveAlphaPhraseReplacementForNumberNegative(self):
     number = "2301"
     expectedList = [
         'AD01', 'AE01', 'AF01', 'BD01', 'BE01', 'BF01', 'CD01', 'CE01',
         'CF01'
     ]
     pointer_to_file = checkFileExistance("../data/dictionary")
     alphaPhrasesFromDictionary = getDictionaryData(pointer_to_file)
     actualList = getAlphaPhrasesForEachNumber(number,
                                               alphaPhrasesFromDictionary)
     print(actualList)
     self.assertEqual(expectedList,
                      actualList,
                      msg="Negative test case which will fail")
Пример #9
0
 def testGetDicitonaryData(self):
     pointer_to_dictionary_file = checkFileExistance("../data/dictionary")
     expectedDictionaryData = {
         '2': ['A', 'B', 'C'],
         '3': ['D', 'E', 'F'],
         '4': ['G', 'H', 'I'],
         '5': ['J', 'K', 'L'],
         '6': ['M', 'N', 'O'],
         '7': ['P', 'Q', 'R', 'S'],
         '8': ['T', 'U', 'V'],
         '9': ['W', 'X', 'Y', 'Z']
     }
     actualDictionaryData = getDictionaryData(pointer_to_dictionary_file)
     print(actualDictionaryData)
     self.assertEqual(expectedDictionaryData, actualDictionaryData)