Ejemplo n.º 1
0
    def test_is_phonenumber(self):
        phonenumber = "303-494-0341"
        e = textproc.Processor(phonenumber)
        self.assertTrue(e.is_phonenumber())

        phonenumber1 = "303 494 0341"
        f = textproc.Processor(phonenumber1)
        self.assertTrue(f.is_phonenumber())
Ejemplo n.º 2
0
 def test_is_phonenumber(self):
     goodNumber1 = textproc.Processor("303-345-3695")
     goodNumber2 = textproc.Processor("3033453695")
     goodNumber3 = textproc.Processor("(303) 345-3695")
     badNumber = textproc.Processor("s22-jsm-29sk")
     self.assertEqual(True, goodNumber1.is_phonenumber(),
                      "expected '303-345-3695' to be valid phone number")
     self.assertEqual(True, goodNumber2.is_phonenumber(),
                      "expected '3033453695' to be valid phone number")
     self.assertEqual(True, goodNumber3.is_phonenumber(),
                      "expected '(303) 345-3695' to be valid phone number")
     self.assertEqual(
         False, badNumber.is_phonenumber(),
         "expected 's22-jsm-29sk' to NOT be valid phone number")
Ejemplo n.º 3
0
 def test_is_phonenumber(self):
     phone_number1 = textproc.Processor("303-345-5695")
     phone_number2 = textproc.Processor("3033455554")
     phone_number3 = textproc.Processor("(303) 345-3695")
     bad_Number = textproc.Processor("so1r-mkt-29sk")
     self.assertEqual(True, phone_number1.is_phonenumber(),
                      "expected '303-3453695' to be valid phone number")
     self.assertEqual(True, phone_number2.is_phonenumber(),
                      "expected '3033453695' to be valid phone number")
     self.assertEqual(True, phone_number3.is_phonenumber(),
                      "expected '(303) 345-3695' to be valid phone number")
     self.assertEqual(
         False, bad_Number.is_phonenumber(),
         "expected 'so1r-mkt-29sk' to NOT be valid phone number")
Ejemplo n.º 4
0
 def test_count(self):
     # verify the functionality of count()
     test_texts = [
         '1234', 'phi phi pho phum', 'the cake is a lie', '99 red balloons'
     ]
     for text in test_texts:
         p = textproc.Processor(text)
         self.assertEqual(p.count(), len(text), "length is off: " + text)
Ejemplo n.º 5
0
 def test_count_numeric(self):
     # verify the functionality of count_numeric()
     test_texts = [
         'abcde', 'abcde9', '9999!23*&A', 'ABC', '239831*&71 , !%', '000'
     ]
     test_solutions = [0, 1, 6, 0, 8, 3]
     for index in range(len(test_texts)):
         p = textproc.Processor(test_texts[index])
         self.assertEqual(
             p.count_numeric(), test_solutions[index],
             "numeric characters count is off: " + str(test_texts[index]))
Ejemplo n.º 6
0
 def test_count_vowels(self):
     text = 'didthiswork'
     num = 0
     for i in text:
         if (i == 'a') or (i == 'e') or (i == 'i') or (i
                                                       == 'o') or (i
                                                                   == 'u'):
             num += 1
     p = textproc.Processor(text)
     self.assertEqual(p.count_vowels(), num,
                      "count of 'text' does not match count of input")
Ejemplo n.º 7
0
 def test_count_vowels(self):
     # verify the functionality of the count_vowels()
     test_texts = [
         'abcde', 'abcde9', '9999!23*&A', 'ABC', '239831*&71 , !%', 'aeiou',
         'BCDFGHJKLMNPQRSTVWXYZ'
     ]
     test_solutions = [2, 2, 1, 1, 0, 5, 0]
     for index in range(len(test_texts)):
         p = textproc.Processor(test_texts[index])
         self.assertEqual(
             p.count_vowels(), test_solutions[index],
             "count of vowels is off: " + str(test_texts[index]))
Ejemplo n.º 8
0
 def test_count_alpha(self):
     # verify the functionality of count_alpha()
     test_texts = [
         'abcde', 'abcde9', '9999!23*&A', 'ABC', '239831*&71 , !%'
     ]
     test_solutions = [5, 5, 1, 3, 0]
     for index in range(len(test_texts)):
         p = textproc.Processor(test_texts[index])
         self.assertEqual(
             p.count_alpha(), test_solutions[index],
             "alphabetic characters count is off: " +
             str(test_texts[index]))
Ejemplo n.º 9
0
 def test_is_phonenumber(self):
     #verify the functionality of is_phonenumber()
     test_texts = [
         '303-333-3333', '(333)-333-3333', '303-3333333', '303333-3333',
         'abc-ab-abcd', '99-9999-9999', '333-(33)3-3333'
     ]
     test_solutions = [True, True, False, False, False, False, False]
     for index in range(len(test_texts)):
         p = textproc.Processor(test_texts[index])
         self.assertEqual(
             p.is_phonenumber(), test_solutions[index],
             "phone number verificaiton is off: " + str(test_texts[index]) +
             str((p.is_phonenumber())))
Ejemplo n.º 10
0
 def test_constructor(self):
     # verify the constructor raises an error if not passed a string
     # test int, float and binary as input to test
     test_input = [9, 9.0, True]
     for test in test_input:
         test_result = False
         try:
             textproc.Processor(test)
         except textproc.TextProcError:
             test_result = True
         self.assertEqual(
             True, test_result,
             "constructor input error- taking in: " + str(test))
Ejemplo n.º 11
0
 def test_count_alpha(self):
     text = "abdFg123"
     pro = textproc.Processor(text)
     self.assertEqual(pro.count_alpha(), 5, "'text' does not match input")
Ejemplo n.º 12
0
 def test_count_vowels(self):
     vowels = "aeioutuvmAE"
     d = textproc.Processor(vowels)
     self.assertEqual(d.count_vowels(), 8)
Ejemplo n.º 13
0
 def test_count_numeric(self):
     numeric = "12345abcdef"
     c = textproc.Processor(numeric)
     self.assertEqual(c.count_numeric(), 5)
Ejemplo n.º 14
0
 def test_count_alpha(self):
     text = "F8o42Ur"
     p = textproc.Processor(text)
     self.assertEqual(4, p.count_alpha(),
                      "Expected p.count_alpha() to return 4")
Ejemplo n.º 15
0
 def test_count_numeric(self):
     text = "adf123"
     pro = textproc.Processor(text)
     self.assertEqual(pro.count_numeric(), 3, "'text' does not match input")
Ejemplo n.º 16
0
 def test_count_vowels(self):
     text = "cuboulderis"
     p = textproc.Processor(text)
     self.assertEqual(p.count_vowels(), 5, "'text' does not match input")
Ejemplo n.º 17
0
 def test4c(self):
     text = 'Abc1'
     p = textproc.Processor(text)
     cnt = p.count_numeric()
     self.assertEqual(cnt, 1, "wrong")
Ejemplo n.º 18
0
 def test_string(self):
     text = "123"
     # without double quote it will give an error that the processor requires a sring
     p = textproc.Processor(text)
     self.assertEqual(p.text, text, "'text' does not match input")
Ejemplo n.º 19
0
 def test_count(self):
     string = "356adff&*&^lkio -s2"
     a = textproc.Processor(string)
     self.assertEqual(a.count(), 19)