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())
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")
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")
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)
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]))
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")
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]))
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]))
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())))
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))
def test_count_alpha(self): text = "abdFg123" pro = textproc.Processor(text) self.assertEqual(pro.count_alpha(), 5, "'text' does not match input")
def test_count_vowels(self): vowels = "aeioutuvmAE" d = textproc.Processor(vowels) self.assertEqual(d.count_vowels(), 8)
def test_count_numeric(self): numeric = "12345abcdef" c = textproc.Processor(numeric) self.assertEqual(c.count_numeric(), 5)
def test_count_alpha(self): text = "F8o42Ur" p = textproc.Processor(text) self.assertEqual(4, p.count_alpha(), "Expected p.count_alpha() to return 4")
def test_count_numeric(self): text = "adf123" pro = textproc.Processor(text) self.assertEqual(pro.count_numeric(), 3, "'text' does not match input")
def test_count_vowels(self): text = "cuboulderis" p = textproc.Processor(text) self.assertEqual(p.count_vowels(), 5, "'text' does not match input")
def test4c(self): text = 'Abc1' p = textproc.Processor(text) cnt = p.count_numeric() self.assertEqual(cnt, 1, "wrong")
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")
def test_count(self): string = "356adff&*&^lkio -s2" a = textproc.Processor(string) self.assertEqual(a.count(), 19)