You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

2 days ago
# -*- coding: utf-8 -*-
"""票 02 输入:占位示例端点 × 四套件 specimens 并集 的覆盖差集。"""
import io, sys, json, re, glob, pathlib
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
DOCS = pathlib.Path(r'D:\code\crm-api-docs\A4 客户管理')
ph = {}
for f in DOCS.rglob('*.bru'):
if f.name == 'folder.bru':
continue
t = f.read_text(encoding='utf-8-sig')
if '非真实返回' in t:
m = re.search(r'^\s*`(GET|POST)\s+([^`?]+)', t, re.M)
if m:
key = m.group(1) + ' ' + m.group(2).strip()
degen = ('"data": null' in t) or ('data: null' in t)
ph[key] = (str(f.relative_to(DOCS)), degen)
print('placeholder endpoints:', len(ph))
def norm(k):
return re.sub(r'/\d{15,}', '/{id}', k)
union = set()
for p in (glob.glob('.scratch/customer-e2e-r2/specimens-*.json')
+ glob.glob('.scratch/customer-contact-graph/e2e-graph-specimens.json')):
d = json.load(open(p, encoding='utf-8'))
for k in d:
union.add(norm(k))
print('specimen union:', len(union))
cov = unc = 0
for k, (rel, degen) in sorted(ph.items()):
if norm(k) in union or k in union:
cov += 1
else:
unc += 1
print(f' 未覆盖: {k} [{rel}] data:null形态={degen}')
print(f'covered={cov} uncovered={unc}')