提交
This commit is contained in:
1 parent
0e1b750457
commit
8c49021d38
93 files changed
+22731
-12107
No files matched your search
@@ -4,6 +4,7 @@ from datetime import datetime
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.crud.oa_instance_draft import DraftAccessError, row_to_dict
|
||||
from app.services.oa_related_approval import flatten_form_fields_for_summary
|
||||
|
||||
|
||||
class TestOaInstanceDraftRowToDict(unittest.TestCase):
|
||||
@@ -49,6 +50,25 @@ class TestOaInstanceDraftRowToDict(unittest.TestCase):
|
||||
err = DraftAccessError("草稿不存在或无权访问")
|
||||
self.assertEqual(str(err), "草稿不存在或无权访问")
|
||||
|
||||
def test_preview_fields_first_three(self):
|
||||
schema = {
|
||||
"rule": [
|
||||
{"type": "input", "field": "a", "title": "数字输入框"},
|
||||
{"type": "input", "field": "b", "title": "出差事由"},
|
||||
{"type": "input", "field": "c", "title": "出差天数"},
|
||||
{"type": "input", "field": "d", "title": "备注"},
|
||||
]
|
||||
}
|
||||
data = {"a": "123", "b": "开会", "c": "4", "d": "忽略"}
|
||||
preview = [
|
||||
{"label": f.get("label") or "", "value": f.get("value") or ""}
|
||||
for f in flatten_form_fields_for_summary(schema, data)[:3]
|
||||
]
|
||||
self.assertEqual(len(preview), 3)
|
||||
self.assertEqual(preview[0], {"label": "数字输入框", "value": "123"})
|
||||
self.assertEqual(preview[1], {"label": "出差事由", "value": "开会"})
|
||||
self.assertEqual(preview[2], {"label": "出差天数", "value": "4"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user