创建 TestGetHtml.py
parent
ded28f6a1e
commit
1174b225a7
|
|
@ -0,0 +1,73 @@
|
|||
import unittest
|
||||
|
||||
from app.views import *
|
||||
|
||||
|
||||
class HtmlTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
app.testing = True # 设置 Flask 应用为测试模式
|
||||
self.client = app.test_client() # 创建一个测试客户端
|
||||
|
||||
def test_get_course_info(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/course-info')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
def test_get_attendance(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/attendance')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
def test_get_announcement(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/announcement')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
def test_get_attendance_reminder(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/attendance-reminder')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
def test_get_course_category(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/course-category')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
def test_get_attendance_teacher(self):
|
||||
# 测试 GET 请求
|
||||
response = self.client.get('/attendance-teacher')
|
||||
|
||||
# 验证响应状态码
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# 验证响应的Content-Type头部值
|
||||
self.assertIn('text/html', response.content_type)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue