更新
This commit is contained in:
@@ -1121,6 +1121,76 @@ def test_appointment_history_phone_is_fail_closed_without_phone_plain(
|
||||
dialog.close()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("locked", [False, True])
|
||||
def test_doctor_can_save_clinical_fields_without_resubmitting_masked_identity(
|
||||
application: QApplication,
|
||||
locked: bool,
|
||||
) -> None:
|
||||
class MaskedRepository(VisualRepository):
|
||||
def check_diagnosis_phone(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
raise AssertionError("a masked phone must not be checked as plaintext")
|
||||
|
||||
def check_diagnosis_id_card(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
raise AssertionError("a masked identity must not be checked as plaintext")
|
||||
|
||||
repository = MaskedRepository(locked=locked)
|
||||
for source in (repository.detail["diagnosis"], repository.detail["patient"]):
|
||||
source["phone"] = "156****7862"
|
||||
source["id_card"] = "1101**********1234"
|
||||
dialog = _open_dialog(
|
||||
application, (1024, 640), mode="edit", repository=repository,
|
||||
permissions=PermissionSet(["tcm.diagnosis/detail", "tcm.diagnosis/edit"]),
|
||||
)
|
||||
saved = []
|
||||
dialog.saved.connect(lambda: saved.append(True))
|
||||
try:
|
||||
assert dialog.edit_fields["phone"].isReadOnly()
|
||||
assert dialog.edit_fields["phone"].toPlainText() == "156****7862"
|
||||
assert dialog.edit_fields["id_card"].isReadOnly()
|
||||
dialog.edit_fields["chief_complaint"].setPlainText("口渴较前改善")
|
||||
dialog._save()
|
||||
assert saved == [True]
|
||||
assert len(repository.updates) == 1
|
||||
payload = repository.updates[0]
|
||||
assert payload["chief_complaint"] == "口渴较前改善"
|
||||
assert "phone" not in payload and "id_card" not in payload
|
||||
assert "156****7862" not in str(payload)
|
||||
assert "1101**********1234" not in str(payload)
|
||||
finally:
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_plain_phone_permission_keeps_validation_and_duplicate_checks(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
class PlainRepository(VisualRepository):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.phone_checks = []
|
||||
|
||||
def check_diagnosis_phone(self, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
self.phone_checks.append(dict(payload))
|
||||
return {"exists": False}
|
||||
|
||||
repository = PlainRepository()
|
||||
dialog = _open_dialog(
|
||||
application, (1024, 640), mode="edit", repository=repository,
|
||||
permissions=PermissionSet(["tcm.diagnosis/edit", "tcm.diagnosis/phonePlain"]),
|
||||
)
|
||||
try:
|
||||
assert not dialog.edit_fields["phone"].isReadOnly()
|
||||
dialog.edit_fields["phone"].setPlainText("156****7862")
|
||||
dialog._save()
|
||||
assert not repository.phone_checks
|
||||
assert not repository.updates
|
||||
dialog.edit_fields["phone"].setPlainText("15600007862")
|
||||
dialog._save()
|
||||
assert repository.phone_checks == [{"id": 501, "phone": "15600007862"}]
|
||||
assert repository.updates[-1]["phone"] == "15600007862"
|
||||
finally:
|
||||
dialog.close()
|
||||
|
||||
|
||||
def test_order_detail_action_requires_exact_permission(application: QApplication) -> None:
|
||||
repository = VisualRepository()
|
||||
dialog = _open_dialog(
|
||||
|
||||
Reference in New Issue
Block a user