test:竖式区勾一块要入库 6 道(扫描入库展开)
This commit is contained in:
@@ -129,6 +129,28 @@ class ScanFlowTest(unittest.TestCase):
|
|||||||
svc.import_scan_picks(self.conn, self.gid, self.cid, "math", d["draft_id"], [9, 10])
|
svc.import_scan_picks(self.conn, self.gid, self.cid, "math", d["draft_id"], [9, 10])
|
||||||
self.assertEqual(ctx.exception.code, "NO_PICKS")
|
self.assertEqual(ctx.exception.code, "NO_PICKS")
|
||||||
|
|
||||||
|
def test_multi_question_block_expands(self):
|
||||||
|
"""勾一块竖式区(6 行),应当入库 6 道,不是 1 道。"""
|
||||||
|
d = self._detect()
|
||||||
|
subs = [{"stem": f"{e} =", "answer": a, "judge_type": "calc"}
|
||||||
|
for e, a in [("1.8+0.6", "2.4"), ("6.5-2.9", "3.6"), ("40×65", "2600")]]
|
||||||
|
block = d["blocks"][0]
|
||||||
|
with mock.patch.object(
|
||||||
|
scanflow, "recognize_block",
|
||||||
|
return_value={"stem": "1.8+0.6\n6.5-2.9\n40×65", "judge_type": "card",
|
||||||
|
"options": None, "answer": None, "page_answer": None,
|
||||||
|
"source": "page", "subs": subs},
|
||||||
|
):
|
||||||
|
paper = svc.import_scan_picks(
|
||||||
|
self.conn, self.gid, self.cid, "math", d["draft_id"], [block["i"]]
|
||||||
|
)
|
||||||
|
self.assertEqual(len(paper["questions"]), 3)
|
||||||
|
self.assertEqual(paper["ocr"]["picked"], 1, "调用方勾的是 1 块")
|
||||||
|
got = [r["stem"] for r in self.conn.execute(
|
||||||
|
"SELECT stem FROM mistakes WHERE child_id=? ORDER BY id", (self.cid,))]
|
||||||
|
self.assertEqual(len(got), 3)
|
||||||
|
self.assertTrue(any("40×65" in s for s in got))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user