geng
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from datetime import date, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -276,13 +277,15 @@ class VisualRepository:
|
||||
) -> dict[str, Any]:
|
||||
assert diagnosis_id == 501
|
||||
self.tracking_calls.append((start_date, end_date))
|
||||
newest_date = end_date or date.today().isoformat()
|
||||
previous_date = (date.fromisoformat(newest_date) - timedelta(days=1)).isoformat()
|
||||
return {
|
||||
"blood_records": [
|
||||
{
|
||||
"id": 6201,
|
||||
"diagnosis_id": 501,
|
||||
"patient_id": 1501,
|
||||
"record_date": "2026-08-10",
|
||||
"record_date": newest_date,
|
||||
"fasting_blood_sugar": 8.2,
|
||||
"systolic_pressure": 146,
|
||||
"source": 1,
|
||||
@@ -291,7 +294,7 @@ class VisualRepository:
|
||||
"id": 6202,
|
||||
"diagnosis_id": 501,
|
||||
"patient_id": 1501,
|
||||
"record_date": "2026-08-10",
|
||||
"record_date": newest_date,
|
||||
"postprandial_blood_sugar": 12.4,
|
||||
"diastolic_pressure": 92,
|
||||
"western_medicine": "二甲双胍",
|
||||
@@ -300,7 +303,7 @@ class VisualRepository:
|
||||
"id": 6203,
|
||||
"diagnosis_id": 501,
|
||||
"patient_id": 1501,
|
||||
"record_date": "2026-08-09",
|
||||
"record_date": previous_date,
|
||||
"fasting_blood_sugar": 7.6,
|
||||
"postprandial_blood_sugar": 10.8,
|
||||
},
|
||||
@@ -310,7 +313,7 @@ class VisualRepository:
|
||||
"id": 6301,
|
||||
"diagnosis_id": 501,
|
||||
"patient_id": 1501,
|
||||
"record_date": "2026-08-10",
|
||||
"record_date": newest_date,
|
||||
"breakfast_foods": "燕麦、鸡蛋",
|
||||
"lunch_foods": "杂粮饭",
|
||||
}
|
||||
@@ -320,7 +323,7 @@ class VisualRepository:
|
||||
"id": 6401,
|
||||
"diagnosis_id": 501,
|
||||
"patient_id": 1501,
|
||||
"record_date": "2026-08-09",
|
||||
"record_date": previous_date,
|
||||
"exercise_type": "散步",
|
||||
"duration": 35,
|
||||
"intensity": 2,
|
||||
@@ -331,7 +334,7 @@ class VisualRepository:
|
||||
def list_tracking_notes(self, diagnosis_id: int) -> list[dict[str, Any]]:
|
||||
assert diagnosis_id == 501
|
||||
self.tracking_note_calls += 1
|
||||
return [{"note_date": "2026-08-10", "content": "饭后散步,继续观察。"}]
|
||||
return [{"note_date": date.today().isoformat(), "content": "饭后散步,继续观察。"}]
|
||||
|
||||
def list_diagnosis_todos(
|
||||
self,
|
||||
@@ -871,10 +874,11 @@ def test_tabs_lazy_load_real_repository_data_and_daily_matrix_structure(
|
||||
panel = dialog._daily_panels[1]
|
||||
assert panel.matrix.rowCount() == 11
|
||||
assert panel.matrix.columnCount() == 8
|
||||
newest_header = repository.tracking_calls[-1][1][5:]
|
||||
blood_column = next(
|
||||
column
|
||||
for column in range(1, panel.matrix.columnCount())
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == "08-10"
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == newest_header
|
||||
)
|
||||
assert panel.matrix.item(0, blood_column).text() == "↑ 8.2 · 自录"
|
||||
assert panel.matrix.item(3, blood_column).text() == "↑ 146/92 · 自录"
|
||||
@@ -1270,15 +1274,18 @@ def test_existing_daily_cells_edit_real_records_and_reject_wrong_owner(
|
||||
return payload
|
||||
|
||||
monkeypatch.setattr(diagnosis_module, "DailyRecordEditorDialog", AcceptedEditor)
|
||||
newest_date = date.fromisoformat(repository.tracking_calls[-1][1])
|
||||
newest_header = newest_date.strftime("%m-%d")
|
||||
previous_header = (newest_date - timedelta(days=1)).strftime("%m-%d")
|
||||
blood_column = next(
|
||||
column
|
||||
for column in range(1, panel.matrix.columnCount())
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == "08-10"
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == newest_header
|
||||
)
|
||||
exercise_column = next(
|
||||
column
|
||||
for column in range(1, panel.matrix.columnCount())
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == "08-09"
|
||||
if panel.matrix.horizontalHeaderItem(column).text() == previous_header
|
||||
)
|
||||
blood_role = panel.matrix.item(0, blood_column).data(Qt.ItemDataRole.UserRole)
|
||||
diet_role = panel.matrix.item(6, blood_column).data(Qt.ItemDataRole.UserRole)
|
||||
|
||||
Reference in New Issue
Block a user