test_ethnic.py 554 B

1234567891011121314151617
  1. """民族码表 CRUD 冒烟测试"""
  2. from app.core.database import SessionLocal
  3. from app.crud.ethnic import list_ethnics
  4. def test_list_ethnics_has_han():
  5. db = SessionLocal()
  6. try:
  7. rows = list_ethnics(db)
  8. assert len(rows) >= 56
  9. han = next((r for r in rows if r["ethnicName"] == "汉族"), None)
  10. assert han is not None
  11. assert han["ethnicCode"] == "01"
  12. filtered = list_ethnics(db, keyword="蒙古")
  13. assert any(r["ethnicName"] == "蒙古族" for r in filtered)
  14. finally:
  15. db.close()