gapfill G3: unify all 5 private row_get onto peer_messages.row_get (approvals, automations, marker_tools, todos, wait_ops; resident import retargeted); semantics identical on None/dict/sqlite3.Row, identity tests added
This commit is contained in:
1 parent
b46bf8d7e0
commit
65e8ed3d64
7 files changed
+58
-52
No files matched your search
@@ -2,16 +2,24 @@
|
||||
|
||||
只用标准库 + 内存 SQLite,不联网。锁定点:
|
||||
- 统一身份:auto_memory._row_get 与 lifecycle._row_get 就是
|
||||
peer_messages.row_get 本体(不是又一份复写)。
|
||||
peer_messages.row_get 本体(不是又一份复写);gapfill G3
|
||||
之后 approvals、automations、marker_tools、todos、wait_ops
|
||||
的 row_get 以及 resident.py 导入的 row_get 也是同一本体。
|
||||
- 真实行类型矩阵(None / dict / sqlite3.Row)下取值与回落
|
||||
与三处旧版一致:现值原样回(含 0 / 空串等假值),缺列 /
|
||||
与旧版一致:现值原样回(含 0 / 空串等假值),缺列 /
|
||||
缺键 / 空行回 default(默认 None)。
|
||||
- default 回落差异钉住:三处旧版的默认回落都是 None——
|
||||
- default 回落差异钉住:旧版的默认回落都是 None——
|
||||
auto_memory 旧版 default 参数默认 None,lifecycle 旧版无
|
||||
default 参数一律回 None,peer 旧版回 None;统一后两模块
|
||||
default 参数一律回 None,peer 旧版回 None;统一后各模块
|
||||
调用处仍不传 default,缺失时仍为 None,不算改语义。
|
||||
- 统一路径实测:lifecycle.snapshot_to_dict 在 dict 缺键行与
|
||||
sqlite3.Row 行上都经统一口出正确字段。
|
||||
- gapfill G3 全仓收尾:五处旧版与统一版在真实行类型下
|
||||
语义完全相同(缺键/缺列/空行一律回 None,调用处均不传
|
||||
default),故统一不算改语义;todos / wait_ops 模块
|
||||
docstring 里“不 import cloud 其它模块”的表述同步修正为
|
||||
“除行取值复用 peer_messages(本身只依赖标准库)外不
|
||||
import cloud 其它模块”。
|
||||
"""
|
||||
|
||||
import sqlite3
|
||||
@@ -20,13 +28,23 @@ import unittest
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
import cloud.approvals as approvals
|
||||
import cloud.auto_memory as auto_memory
|
||||
import cloud.automations as automations
|
||||
import cloud.lifecycle as lifecycle
|
||||
import cloud.marker_tools as marker_tools
|
||||
import cloud.todos as todos
|
||||
import cloud.wait_ops as wait_ops
|
||||
from cloud.peer_messages import row_get
|
||||
except ImportError:
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
import cloud.approvals as approvals
|
||||
import cloud.auto_memory as auto_memory
|
||||
import cloud.automations as automations
|
||||
import cloud.lifecycle as lifecycle
|
||||
import cloud.marker_tools as marker_tools
|
||||
import cloud.todos as todos
|
||||
import cloud.wait_ops as wait_ops
|
||||
from cloud.peer_messages import row_get
|
||||
|
||||
|
||||
@@ -48,6 +66,25 @@ class RowGetUnifiedTestCase(unittest.TestCase):
|
||||
self.assertIs(auto_memory._row_get, row_get)
|
||||
self.assertIs(lifecycle._row_get, row_get)
|
||||
|
||||
def test_gapfill_five_modules_are_the_same_function(self):
|
||||
# gapfill G3:五处私有 row_get 已删,模块属性就是统一本体;
|
||||
# resident.py 同样从 peer_messages 导入,故一并钉住。
|
||||
import cloud.resident as resident
|
||||
|
||||
self.assertIs(approvals.row_get, row_get)
|
||||
self.assertIs(automations.row_get, row_get)
|
||||
self.assertIs(marker_tools.row_get, row_get)
|
||||
self.assertIs(todos.row_get, row_get)
|
||||
self.assertIs(wait_ops.row_get, row_get)
|
||||
self.assertIs(resident.row_get, row_get)
|
||||
# 五处调用处均不传 default,缺失回落仍是 None。
|
||||
for fn in (approvals.row_get, automations.row_get,
|
||||
marker_tools.row_get, todos.row_get,
|
||||
wait_ops.row_get):
|
||||
self.assertIsNone(fn({}, "nope"))
|
||||
self.assertIsNone(fn(None, "nope"))
|
||||
self.assertEqual(fn({"a": 0}, "a"), 0)
|
||||
|
||||
def test_real_row_type_matrix(self):
|
||||
full, partial = _sqlite_row()
|
||||
# 现值原样回(含假值 0,不被当成缺失)。
|
||||
|
||||
Reference in new issue
Block a user