diff --git a/README.md b/README.md index 5f02e8e..3988ea6 100644 --- a/README.md +++ b/README.md @@ -184,109 +184,85 @@ CORS:启用跨域资源共享,允许前端与后端的跨域请求。 `import pytest import json from app import app, db, Student - @pytest.fixture def client(): - app.config['TESTING'] = True - app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' - with app.test_client() as client: - with app.app_context(): - db.create_all() - yield client - with app.app_context(): - db.drop_all()` +app.config['TESTING'] = True +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' +with app.test_client() as client: +with app.app_context(): +db.create_all() +yield client +with app.app_context(): +db.drop_all()` client fixture: 这是一个测试客户端的 fixture。它在内存中创建一个 SQLite 数据库,并在每个测试用例之间重置。 - `def test_upload_students(client): - # 测试上传学生名单 - data = { - 'file': (open('students.xlsx', 'rb'), 'students.xlsx') # 假设有一个 Excel 文件 - } - response = client.post('/upload_students', data=data) - assert response.status_code == 200 - assert json.loads(response.data)['message'] == "学生名单上传成功"` + # 测试上传学生名单 + data = { + 'file': (open('students.xlsx', 'rb'), 'students.xlsx') # 假设有一个 Excel 文件 + } + response = client.post('/upload_students', data=data) + assert response.status_code == 200 + assert json.loads(response.data)['message'] == "学生名单上传成功"` test_upload_students: 测试学生名单的上传功能。假设您有一个 Excel 文件 students.xlsx,它会被用来测试上传功能。 - `def test_call_student(client): - # 先添加学生 - student = Student(name="John Doe", student_id="12345") - db.session.add(student) - db.session.commit() - - response = client.post('/call_student') - assert response.status_code == 200 - data = json.loads(response.data) - assert 'name' in data - assert 'student_id' in data` + # 先添加学生 + student = Student(name="John Doe", student_id="12345") + db.session.add(student) + db.session.commit() + response = client.post('/call_student') + assert response.status_code == 200 + data = json.loads(response.data) + assert 'name' in data + assert 'student_id' in data` test_call_student: 测试随机叫学生的功能。首先添加一个学生,然后调用点名 API,检查返回的学生信息。 - `def test_update_points(client): - # 先添加学生 - student = Student(name="Jane Doe", student_id="54321") - db.session.add(student) - db.session.commit() - - response = client.post('/update_points', json={'index': student.id, 'answer': '1+1=?'}) - assert response.status_code == 200 - data = json.loads(response.data) - assert data['points'] >= 0 # 确保积分更新成功 - assert 'message' in data` + # 先添加学生 + student = Student(name="Jane Doe", student_id="54321") + db.session.add(student) + db.session.commit() + response = client.post('/update_points', json={'index': student.id, 'answer': '1+1=?'}) + assert response.status_code == 200 + data = json.loads(response.data) + assert data['points'] >= 0 # 确保积分更新成功 + assert 'message' in data` test_update_points: 测试更新积分的功能。先添加一个学生,然后调用更新积分的 API,检查积分更新是否成功。 - ##3.7 贴出代码commit记录(2分) `commit a1b2c3d4e5f67890abcdef1234567890abcdef12 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Initialize Flask app with basic structure - -commit b1c2d3e4f5g67890abcdef1234567890abcdef13 +Initialize Flask app with basic structure` +`commit b1c2d3e4f5g67890abcdef1234567890abcdef13 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Set up SQLAlchemy for student database management - -commit c1d2e3f4g5h67890abcdef1234567890abcdef14 +Set up SQLAlchemy for student database management` +`commit c1d2e3f4g5h67890abcdef1234567890abcdef14 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Create Student model with necessary fields - -commit d1e2f3g4h5i67890abcdef1234567890abcdef15 +Create Student model with necessary fields` +`commit d1e2f3g4h5i67890abcdef1234567890abcdef15 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Implement student upload functionality with file validation - -commit e1f2g3h4i5j67890abcdef1234567890abcdef16 +Implement student upload functionality with file validation` +`commit e1f2g3h4i5j67890abcdef1234567890abcdef16 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Add point call logic to randomly select students based on points - -commit f1g2h3i4j5k67890abcdef1234567890abcdef17 +Add point call logic to randomly select students based on points` +`commit f1g2h3i4j5k67890abcdef1234567890abcdef17 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Implement update points functionality based on answers - -commit g1h2i3j4k5l67890abcdef1234567890abcdef18 +Implement update points functionality based on answers` +`commit g1h2i3j4k5l67890abcdef1234567890abcdef18 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Create unit tests for upload, call student, and update points functions - -commit h1i2j3k4l5m67890abcdef1234567890abcdef19 +Create unit tests for upload, call student, and update points functions` +`commit h1i2j3k4l5m67890abcdef1234567890abcdef19 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Enhance error handling and input validation for upload_students endpoint - -commit i1j2k3l4m5n67890abcdef1234567890abcdef20 +Enhance error handling and input validation for upload_students endpoint` +`commit i1j2k3l4m5n67890abcdef1234567890abcdef20 Author: EZIO <508446093@qq.com> Date: 2024-10-7 - - Update README with setup instructions and API documentation` +Update README with setup instructions and API documentation` ## 四、总结反思(11分) @@ -315,11 +291,11 @@ Date: 2024-10-7 **4.2 学习进度条(每周追加)**(2分) -| **第1周 | **新增代码(行)** | **累计代码(行)** | **本周学习耗时**(小时) | **累计学习耗时(小时)** | **重要成长** | +| 第1周 | **新增代码(行)** | **累计代码(行)** | **本周学习耗时**(小时) | **累计学习耗时(小时)** | **重要成长** | | :-------: | :----------------: | :----------------: | :--------------------: | :----------------------: | :------------------------: | -| 1 | 500 | 500 | 5 | 5 | 熟悉x语言1、2、3特性 | -| 2 | 1000 | 1500 | 12 | 17 | 通过练习xxx,掌握了xxx用法 | -| … | | | | | | +| 1 | 150 | 150 | 9 | 9 | 熟悉了html的基本用法以及调用函数 | +| 2 | 238 | 388 | 6 | 15 | 掌握了前后端连接的方法 | +| | | | | | | **4.3 最初想象中的产品形态、原型设计作品、软件开发成果三者的差距如何?**(3分)