示例#1
0
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)
示例#2
0
 def test_pyramid_word_invalid_capitalize_text_is_false(self):
     text = "Felicidad"
     result = is_pyramid_word(text)
     self.assertFalse(result)
示例#3
0
 def test_pyramid_word_valid_capitalize_text_is_true(self):
     text = "Banana"
     result = is_pyramid_word(text)
     self.assertTrue(result)
示例#4
0
 def test_pyramid_word_invalid_input_is_false(self):
     text = 1
     result = is_pyramid_word(text)
     self.assertFalse(result)
示例#5
0
 def test_pyramid_word_valid_text_nonpyramid_is_false(self):
     text = "familia"
     result = is_pyramid_word(text)
     self.assertFalse(result)
示例#6
0
 def test_pyramid_word_invalid_text_has_tabs_is_false(self):
     text = "catalina\t"
     result = is_pyramid_word(text)
     self.assertFalse(result)
示例#7
0
 def test_pyramid_word_valid_text_has_tabs_is_true(self):
     text = "banana\t"
     result = is_pyramid_word(text)
     self.assertTrue(result)
示例#8
0
 def test_pyramid_empty_text_is_false(self):
     text = ""
     result = is_pyramid_word(text)
     self.assertFalse(result)