feat(market): 完善临床科研与委托加工上线能力
补齐项目组负责人审批、费用信息、合作客户、生产出库菜单、申请单号 LCKY 前缀及配套 SQL 迁移,并同步相关前后端与单测。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7a3c58ed99
commit
c22a0d1eb0
77 files changed
+8375
-1869
No files matched your search
@@ -0,0 +1,62 @@
|
||||
"""委托加工自定义业务类型 CRUD"""
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from app.crud import contract_processing_category as crud
|
||||
|
||||
|
||||
class TestContractProcessingCategoryValidation(unittest.TestCase):
|
||||
def test_reject_reserved_fixed_code(self):
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
crud._assert_valid_name("nk")
|
||||
self.assertIn("预置", str(ctx.exception))
|
||||
|
||||
def test_reject_reserved_fixed_label(self):
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
crud._assert_valid_name("胎盘冻干粉")
|
||||
self.assertIn("预置", str(ctx.exception))
|
||||
|
||||
def test_reject_empty(self):
|
||||
with self.assertRaises(ValueError):
|
||||
crud._assert_valid_name(" ")
|
||||
|
||||
def test_accept_custom(self):
|
||||
self.assertEqual(crud._assert_valid_name(" 外泌体定制A "), "外泌体定制A")
|
||||
|
||||
|
||||
class TestContractProcessingCategoryCreate(unittest.TestCase):
|
||||
@patch("app.crud.contract_processing_category._exists_name", return_value=False)
|
||||
@patch("app.crud.contract_processing_category.generate_uuid", return_value="cat-1")
|
||||
def test_create_ok(self, _uuid, _exists):
|
||||
db = MagicMock()
|
||||
obj = crud.create_category(
|
||||
db,
|
||||
category_name="定制产品B",
|
||||
tenant_no="zkxw",
|
||||
biz_type="contract_processing",
|
||||
user_id="u1",
|
||||
commit=False,
|
||||
)
|
||||
self.assertEqual(obj.category_name, "定制产品B")
|
||||
self.assertEqual(obj.biz_type, "contract_processing")
|
||||
db.add.assert_called()
|
||||
db.flush.assert_called()
|
||||
|
||||
@patch("app.crud.contract_processing_category._exists_name", return_value=False)
|
||||
@patch("app.crud.contract_processing_category.generate_uuid", return_value="cat-bex")
|
||||
def test_create_basic_experiment_ok(self, _uuid, _exists):
|
||||
db = MagicMock()
|
||||
obj = crud.create_category(
|
||||
db,
|
||||
category_name="定制科研课题A",
|
||||
tenant_no="zkxw",
|
||||
biz_type="basic_experiment",
|
||||
user_id="u1",
|
||||
commit=False,
|
||||
)
|
||||
self.assertEqual(obj.biz_type, "basic_experiment")
|
||||
self.assertEqual(obj.category_name, "定制科研课题A")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user