def pyramid_word(): """ This is a POST method that retreives the information from the HTML input element. It takes the user input calls the is_pyramid_word method to test if the word is pyramid or not. After rendering the result.html template, it displays a message indicating if the entered word is pyramid or not. :param: none :return: a rendered HTML file, containing a display message. """ # take user input user_input = request.form['word'] # check for pyramid if is_pyramid_word(user_input): msg = "It's pyramid!" else: msg = "Not a pyramid word :(" return render_template('result.html', msg=msg)
def test_pyramid_word_invalid_capitalize_text_is_false(self): text = "Felicidad" result = is_pyramid_word(text) self.assertFalse(result)
def test_pyramid_word_valid_capitalize_text_is_true(self): text = "Banana" result = is_pyramid_word(text) self.assertTrue(result)
def test_pyramid_word_invalid_input_is_false(self): text = 1 result = is_pyramid_word(text) self.assertFalse(result)
def test_pyramid_word_valid_text_nonpyramid_is_false(self): text = "familia" result = is_pyramid_word(text) self.assertFalse(result)
def test_pyramid_word_invalid_text_has_tabs_is_false(self): text = "catalina\t" result = is_pyramid_word(text) self.assertFalse(result)
def test_pyramid_word_valid_text_has_tabs_is_true(self): text = "banana\t" result = is_pyramid_word(text) self.assertTrue(result)
def test_pyramid_empty_text_is_false(self): text = "" result = is_pyramid_word(text) self.assertFalse(result)