示例#1
0
def getInputData(phone_directory_path, dictionary_path):
    pointer_to_phone_directory = checkFileExistance(
        phone_directory_path)  # method to check whether the file exist or not
    pointer_to_dictionary = checkFileExistance(
        dictionary_path)  # method to check whether the file exist or not

    listOfNumbersFromDirectory = getInputDataOfPhoneDirectory(
        pointer_to_phone_directory)
    alphaPhrasesFromDictionary = getInputDataOfDictionary(
        pointer_to_dictionary)

    return listOfNumbersFromDirectory, alphaPhrasesFromDictionary
示例#2
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)
示例#3
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)
 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)
示例#5
0
 def testGetPhoneNumbersData(self):
     pointer_to_directory_file = checkFileExistance(
         "../data/phone-numbers-directory")
     expectedDirectoryData = [
         '95355', '345236016', '2347 7809', '234?6!784', '123400', '2255.63'
     ]
     actualDirectoryData = getListOfNumbersInDirectory(
         pointer_to_directory_file)
     print(actualDirectoryData)
     self.assertEqual(expectedDirectoryData, actualDirectoryData)
 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)
 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)
 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)
 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")
示例#10
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)
示例#11
0
 def testCheckFileExistance(self):
     pointer_to_file = checkFileExistance("../data/dictionary")
     self.assertNotEqual(pointer_to_file, False)
     pointer_to_file.close()