def submit(): data = request.form first_name = data['first_name'] last_name = data['last_name'] id = data['id'] tel = data['tel'] error_message = "" if validate_name(first_name) is not True: error_message = "กรุณากรอกชื่อให้ถูกต้อง" return render_template('error.html', message=error_message) if validate_name(last_name) is not True: error_message = "กรุณากรอกนามสกุลให้ถูกต้อง" return render_template('error.html', message=error_message) if validate_id(id) is not True: error_message = 'กรุณากรอกเลขบัตรประจำตัวให้ถูกต้อง' return render_template('error.html', message=error_message) if validate_phone_number(tel) is not True: error_message = 'กรุณากรอกหมายเลขโทรศัพท์ให้ถูกต้อง' return render_template('error.html', message=error_message) return render_template('success.html', first_name=first_name, last_name=last_name, id=id, tel=tel)
def submit(): data = request.form first_name = data['first_name'] last_name = data['last_name'] id = data['id'] tel = data['tel'] error_message = "" if validate_name(first_name) is not True: error_message = 'กรุณากรอกชื่อให้ถูกต้อง' return render_template('error.html', message=error_message) if validate_name(last_name) is not True: error_message = 'กรุณากรอกนามสกุลให้ถูกต้อง' return render_template('error.html', message=error_message) return render_template('success.html', first_name=first_name, last_name=last_name, id=id, tel=tel)
def test_validate_name_with_invalid_input_contain_special(self): self.assertEqual(False, validate_name("!#@///+-="))
def test_validate_name_with_valid_input(self): self.assertEqual(True, validate_name("hanif"))
def test_validate_id_len13(self): self.assertEqual(True, validate_name("1929900744144"))
def test_validate_name_with_invalid_input_special_char3(self): self.assertEqual(False, validate_name("'!*/-+อะไรกันครับเนี่ย $%#@"))
def test_validate_name_with_invalid_input_special_char(self): self.assertEqual(False, validate_name("ff_**"))
def test_validate_name_with_invalid_input_string_of_int(self): self.assertEqual(False, validate_name("12312121"))
def test_validate_name_with_empty_input(self): self.assertEqual(False, validate_name(""))
def test_validate_name_false_with_valid_free(self): self.assertEqual(False, validate_name(""))
def test_validate_name_false_with_valid_specialString(self): self.assertEqual(False, validate_name("thitipong#@]"))
def test_validate_name_with_valid_input_language(self): self.assertEqual(True, validate_name("Wittawat"))
def test_validate_name_with_space(self): self.assertEqual(False, validate_name("chu tima"))
def test_validate_name_with_invalid_input_contain_string_number_special( self): self.assertEqual(False, validate_name("Wittawat*#5000"))
def test_validate_name_with_invalid_input_contain_string_special(self): self.assertEqual(False, validate_name("*#Wittawat"))
def test_validate_name_with_invalid_input_spacial_char(self): self.assertEqual(False, validate_name("มีไรหรอ!"))
def test_validate_name_with_invalid_input_spacial_char_more_one(self): self.assertEqual(False, validate_name("$อะไร@เนี้ย#"))
def test_validate_name_false_with_valid_specString(self): self.assertEqual(False, validate_name("thitipong purinsuwan"))
def test_validate_name_with_without_space(self): self.assertEqual(False, validate_name("ปอ ซ่า"))
def test_validate_name_false_with_valid_hanif5(self): self.assertEqual(False, validate_name("hanif5"))
def test_validate_name_with_invalid_input_contain_string_of_int(self): self.assertEqual(False, validate_name("aaa122"))
def test_validate_name_with_valid_input_name(self): self.assertEqual(True, validate_name("Anna"))
def test_validate_name_with_invalid_input_special_char2(self): self.assertEqual(False, validate_name("'!*/-+$%#@"))
def test_validate_name_with_invalid_input_special_string(self): self.assertEqual(False, validate_name("มิว##!!!"))
def test_validate_name_with_invalid_input_empty_string(self): self.assertEqual(False, validate_name(" "))
def test_validate_name_with_invalid_input_space(self): self.assertEqual(False, validate_name("มิ ว"))
def test_validate_id_len12(self): self.assertEqual(False, validate_name("192990074414"))
def test_validate_name_with_invalid_input_string_of_intstring(self): self.assertEqual(False, validate_name("1denny50"))
def test_validate_name_with_invalid_string_int_input(self): self.assertEqual(False, validate_name("1234"))
def test_validate_name_with_invalid_input_contained_string_of_int(self): self.assertEqual(False, validate_name("ชายปอzaa007"))