feat: 工参小区按制式拆成 CellData_4G、CellData_5G;即席查询补上页面必带参数
两张表列名沿用平台工参表,已有快照由迁移 0008 原样搬过去。即席查询的 result 补 tableParams、columnname,计数补 indexcount=0,缺这些服务端会返回 stat 0。
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from app.nqi import adhoc
|
||||
from app.nqi.client import NqiError
|
||||
|
||||
HEAD = {
|
||||
"tablename": "appdbv3.v_a_common_cfg_lte_cellant_d",
|
||||
"tablename_cn": "4G小区工参",
|
||||
"columnname": "cgi",
|
||||
"columnname_cn": "CGI",
|
||||
"fieldtype": "基础信息",
|
||||
"datatype": "character varying",
|
||||
"columntype": 1,
|
||||
"supporteddimension": None,
|
||||
"supportedtimedimension": None,
|
||||
}
|
||||
|
||||
|
||||
def test_result_json_carries_table_params_like_the_page():
|
||||
payload = json.loads(adhoc._result_json(HEAD, [HEAD]))
|
||||
assert list(payload) == ["result", "tableParams", "columnname"]
|
||||
assert payload["tableParams"] == {"supporteddimension": None, "supportedtimedimension": ""}
|
||||
assert payload["columnname"] == ""
|
||||
assert payload["result"][0]["feild"] == "cgi" and payload["result"][0]["table"] == HEAD["tablename"]
|
||||
|
||||
|
||||
def test_count_sends_indexcount_and_rejects_error_payload(monkeypatch):
|
||||
sent = []
|
||||
replies = [{"count": 37604, "indexcount": "0"}, {"stat": "0", "message": "null"}, {}]
|
||||
|
||||
async def fake_post(client, url, form):
|
||||
sent.append((url.rsplit("/", 1)[-1], form))
|
||||
return replies[len(sent) - 1]
|
||||
|
||||
monkeypatch.setattr(adhoc, "_post_json", fake_post)
|
||||
assert asyncio.run(adhoc._count(None, {"where": "[]"})) == (37604, "0")
|
||||
assert sent[0][0] == "getTableCount" and sent[0][1] == {"where": "[]", "indexcount": "0"}
|
||||
for _ in range(2):
|
||||
with pytest.raises(NqiError):
|
||||
asyncio.run(adhoc._count(None, {"where": "[]"}))
|
||||
Reference in New Issue
Block a user