test(backend): update employee service tests
- tests/test_employee_service.py: update employee service tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import create_engine, func, select
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
from sqlalchemy.pool import StaticPool
|
||||
@@ -115,3 +116,12 @@ def test_disable_employee_marks_status_and_logs_change() -> None:
|
||||
assert persisted is not None
|
||||
assert persisted.employment_status == "停用"
|
||||
assert any(item.action == "停用员工账号" for item in updated.history)
|
||||
|
||||
|
||||
def test_update_employee_rejects_invalid_date_format() -> None:
|
||||
with build_session() as db:
|
||||
service = EmployeeService(db)
|
||||
employee = service.list_employees()[0]
|
||||
|
||||
with pytest.raises(ValueError, match="出生日期格式必须为 YYYY-MM-DD。"):
|
||||
service.update_employee(employee.id, EmployeeUpdate(birth_date="2024/01/01"))
|
||||
|
||||
Reference in New Issue
Block a user