........................................................................ [  1%]
........................................................................ [  3%]
........................................................................ [  4%]
........................................................................ [  6%]
........................................................................ [  7%]
........................................................................ [  9%]
........................................................................ [ 10%]
........................................................................ [ 12%]
........................................................................ [ 13%]
........................................................................ [ 15%]
........................................................................ [ 17%]
........................................................................ [ 18%]
........................................................................ [ 20%]
........................................................................ [ 21%]
........................................................................ [ 23%]
........................................................................ [ 24%]
........................................................................ [ 26%]
........................................................................ [ 27%]
........................................................................ [ 29%]
........................................................................ [ 31%]
........................................................................ [ 32%]
........................................................................ [ 34%]
........................................................................ [ 35%]
........................................................................ [ 37%]
........................................................................ [ 38%]
........................................................................ [ 40%]
...........................................F............................ [ 41%]
........................................................................ [ 43%]
........................................................................ [ 45%]
........................................................................ [ 46%]
.....................................F.................................. [ 48%]
........................................................................ [ 49%]
........................................................................ [ 51%]
........................................................................ [ 52%]
........................................................................ [ 54%]
........................................................................ [ 55%]
........................................................................ [ 57%]
........................................................................ [ 59%]
........................................................................ [ 60%]
........................................................................ [ 62%]
........................................................................ [ 63%]
........................................................................ [ 65%]
........................................................................ [ 66%]
........................................................................ [ 68%]
........................................................................ [ 69%]
........................................................................ [ 71%]
........................................................................ [ 73%]
........................................................................ [ 74%]
........................................................................ [ 76%]
........................................................................ [ 77%]
........................................................................ [ 79%]
........................................................................ [ 80%]
........................................................................ [ 82%]
........................................................................ [ 83%]
........................................................................ [ 85%]
........................................................................ [ 86%]
........................................................................ [ 88%]
........................................................................ [ 90%]
........................................................................ [ 91%]
........................................................................ [ 93%]
........................................................................ [ 94%]
........................................................................ [ 96%]
........................................................................ [ 97%]
........................................................................ [ 99%]
...........................                                              [100%]
=================================== FAILURES ===================================
__________ test_exact_topology_counts_modes_unknowns_and_old_objects ___________

    def test_exact_topology_counts_modes_unknowns_and_old_objects():
        d = doc()
        assert d["fixed_version"]["matched"] and d["fixed_version"]["fields"] == BLOCK["fields"]
        assert len(BLOCK["fields"]) == 74 and len(BLOCK["comments"]) == 0
        assert sum(isinstance(f["value"], dict) for f in BLOCK["fields"]) == 3
        assert sum(f["value"] is None for f in BLOCK["fields"]) == 1
        assert sum(f["role"] == "unknown_saved" for f in BLOCK["fields"]) == 7
        expected = {
            203: 1,
            334: 1,
            340: 1,
            137: 11,
            339: 1,
            373: 11,
            364: 3,
            362: 7,
            363: 0,
            106: 2,
            374: 9,
            370: 1,
            130: 9,
            208: 1,
            376: 1,
            375: 9,
            365: 0,
            335: 2,
            372: 4,
        }
        nodes = {n["id"]: n for n in SOURCE["nodes"]}
        assert {nid: len(n["widgets_values"]) for nid, n in nodes.items()} == expected
        assert {nid for nid, n in nodes.items() if n["mode"] == 4} == {106, 375, 365}
        assert len(SOURCE["links"]) == 22 and "definitions" not in SOURCE
        assert [e[0] for e in SOURCE["links"]] == [
            570,
            621,
            623,
            624,
            625,
            627,
            629,
            648,
            650,
            651,
            653,
            654,
            655,
            656,
            657,
            658,
            659,
            660,
            661,
            662,
            663,
            665,
        ]
        for eid, origin, slot, target, inp, typ in SOURCE["links"]:
            assert eid in nodes[origin]["outputs"][slot]["links"]
            assert nodes[target]["inputs"][inp]["link"] == eid
            assert nodes[target]["inputs"][inp]["type"] == (
                {648: "INT", 661: "INT,FLOAT", 662: "INT,FLOAT"}.get(eid, typ)
            )
        text = "".join(BLOCK["flow"])
        assert all(
            t in text
            for t in [
                "没有warmup",
                "没有per_batch",
                "round(result)",
                "两Combine.audio都未接",
                "临时目录",
                "UE",
                "mode4",
                "0新源注释",
                "冲突不抹平",
                "taichi",
                "提供方",
                "未实跑",
            ]
        )
        assert not BLOCK["counts"]["final_prompt_constructed"]
        resource = "calliope-backend/src/calliope/comfyui/source_reviews.json"
        old = json.loads(subprocess.check_output(["git", "show", "7e76510:" + resource], cwd=REPO))
        now = json.loads((REPO / resource).read_bytes())
        reverse = next(p for p in now if p.endswith("/视频倒放.json"))
        now[reverse].pop("fixed_version_document")
        assert now[PATH].pop("fixed_version_document") == BLOCK
        assert now == old and len(DEFINITIONS) == 18
        old_blocks = [
            r["fixed_version_document"] for r in old.values() if "fixed_version_document" in r
        ]
        assert len(old_blocks) == 16 and sum(len(b["fields"]) for b in old_blocks) == 421
        assert (
            sum(len(b.get("comments", [])) for b in old_blocks) == 14
        )  # separate historical ASR flow note
        assert d["status"] == dict(imported=True, doc_done=False, exec_verified=False)
        assert d["dependencies"]["check_state"] == "unchecked"
        for p in DEFINITIONS:
            if p == PATH:
                continue
            r = copy.deepcopy(REVIEW)
>           r["fixed_version_document"] = old[p]["fixed_version_document"]
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           KeyError: 'fixed_version_document'

calliope-backend/tests/test_nlf_fixed_document.py:280: KeyError
________________ test_exact_document_topology_and_preservation _________________

    def test_exact_document_topology_and_preservation():
        d = doc()
        assert d["fixed_version"]["matched"] and d["fixed_version"]["fields"] == BLOCK["fields"]
        assert len(BLOCK["fields"]) == 27 and len(BLOCK["comments"]) == 1
        assert sum(isinstance(f["value"], dict) for f in BLOCK["fields"]) == 2
        assert len(SOURCE["nodes"]) == 5 and len(SOURCE["links"]) == 4
        assert SOURCE["links"] == [
            [4, 1, 0, 4, 0, "IMAGE"],
            [10, 2, 0, 1, 0, "IMAGE"],
            [11, 2, 3, 9, 0, "VHS_VIDEOINFO"],
            [12, 9, 0, 4, 4, "FLOAT"],
        ]
        nodes = {n["id"]: n for n in SOURCE["nodes"]}
        for edge, origin, slot, target, inp, typ in SOURCE["links"]:
            assert edge in nodes[origin]["outputs"][slot]["links"]
            assert nodes[target]["inputs"][inp]["link"] == edge
            assert nodes[target]["inputs"][inp]["type"] == typ
        assert nodes[9]["widgets_values"] == {} and type(nodes[9]["widgets_values"]) is dict
        assert all(n["mode"] == 0 for n in SOURCE["nodes"])
        assert pointer(SOURCE, BLOCK["comments"][0]["pointer"]) == BLOCK["comments"][0]["text"]
        assert not BLOCK["counts"]["final_prompt_constructed"]
        assert all(
            s in "".join(BLOCK["flow"])
            for s in [
                "未实跑",
                "包同字节不等于提交绑定",
                "loaded_fps",
                "外线覆盖",
                "音频",
                "UE7.5.2",
                "空对象",
                "不是缺键/null/[]",
            ]
        )
        resource = "calliope-backend/src/calliope/comfyui/source_reviews.json"
        previous = json.loads(subprocess.check_output(["git", "show", "fec5cca:" + resource], cwd=REPO))
        current = json.loads((REPO / resource).read_bytes())
        reverse = next(p for p in current if p.endswith("/视频倒放.json"))
        current[reverse].pop("fixed_version_document")
        nlf = next(p for p in current if p.endswith("NLF_视频人物动作骨架获取.json"))
        current[nlf].pop("fixed_version_document")
        assert current[PATH].pop("fixed_version_document") == BLOCK
        assert current == previous and len(DEFINITIONS) == 18
        old = [r["fixed_version_document"] for r in previous.values() if "fixed_version_document" in r]
        assert len(old) == 15 and sum(len(b["fields"]) for b in old) == 394
        assert sum(len(b.get("comments", [])) for b in old) == 13  # one historical ASR flow note
        assert d["status"] == dict(imported=True, doc_done=False, exec_verified=False)
        assert d["dependencies"]["check_state"] == "unchecked"
        assert not doc(path="untrusted.json").get("fixed_version")
        for p in DEFINITIONS:
            if p in [PATH, nlf]:
                continue
            r = copy.deepcopy(REVIEW)
>           r["fixed_version_document"] = previous[p]["fixed_version_document"]
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E           KeyError: 'fixed_version_document'

calliope-backend/tests/test_openpose_fixed_document.py:221: KeyError
=========================== short test summary info ============================
FAILED calliope-backend/tests/test_nlf_fixed_document.py::test_exact_topology_counts_modes_unknowns_and_old_objects
FAILED calliope-backend/tests/test_openpose_fixed_document.py::test_exact_document_topology_and_preservation
2 failed, 4633 passed, 1 warning in 22.05s
